private Image loadImage(ClassLoader classLoader, String base, String src) throws IOException { URL url = getResourceUrl(classLoader, base, src); return ((DeviceDisplayImpl) getDeviceDisplay()).createSystemImage(url); }
/** * @deprecated */ public void init(EmulatorContext context) { super.init(context); }
private static XMLElement loadDeviceDescriptor(ClassLoader classLoader, String descriptorLocation) throws IOException { InputStream descriptor = classLoader.getResourceAsStream(descriptorLocation); if (descriptor == null) { throw new IOException("Cannot find descriptor at: " + descriptorLocation); } XMLElement doc; try { doc = loadXmlDocument(descriptor); } finally { IOUtils.closeQuietly(descriptor); } String parent = doc.getStringAttribute("extends"); if (parent != null) { return inheritXML(loadDeviceDescriptor(classLoader, expandResourcePath(besourceBase(descriptorLocation), parent)), doc, "/"); } return doc; }
loadSkinVersion(doc); hasRepeatEvents = false; ((FontManagerImpl) getFontManager()).setAntialiasing(false); parseDisplay(classLoader, base, doc.getChild("display")); parseSystemProperties(tmp); } else if (tmp.getName().equals("img") && !((DeviceDisplayImpl) getDeviceDisplay()).isResizable()) { try { if (tmp.getStringAttribute("name").equals("normal")) { normalImage = loadImage(classLoader, base, tmp.getStringAttribute("src")); } else if (tmp.getStringAttribute("name").equals("over")) { overImage = loadImage(classLoader, base, tmp.getStringAttribute("src")); } else if (tmp.getStringAttribute("name").equals("pressed")) { pressedImage = loadImage(classLoader, base, tmp.getStringAttribute("src")); parseFonts(classLoader, base, tmp); } else if (tmp.getName().equals("input") || tmp.getName().equals("keyboard")) { parseInput(tmp);
private void parseInput(XMLElement tmp) { DeviceDisplayImpl deviceDisplay = (DeviceDisplayImpl) getDeviceDisplay(); boolean resizable = deviceDisplay.isResizable(); XMLElement tmp_keyboard = (XMLElement) e_keyboard.nextElement(); if (tmp_keyboard.getName().equals("haspointerevents")) { hasPointerEvents = parseBoolean(tmp_keyboard.getContent()); } else if (tmp_keyboard.getName().equals("haspointermotionevents")) { hasPointerMotionEvents = parseBoolean(tmp_keyboard.getContent()); } else if (tmp_keyboard.getName().equals("hasrepeatevents")) { hasRepeatEvents = parseBoolean(tmp_keyboard.getContent()); } else if (tmp_keyboard.getName().equals("button")) { Shape shape = null; shape = getRectangle(tmp_button); } else if (tmp_button.getName().equals("polygon") && !resizable) { shape = getPolygon(tmp_button); getButtons().addElement( deviceDisplay.createButton(skinVersion, tmp_keyboard.getStringAttribute("name"), shape, keyCode, tmp_keyboard.getStringAttribute("key"), tmp_keyboard XMLElement tmp_button = (XMLElement) e_button.nextElement(); if (tmp_button.getName().equals("rectangle") && !resizable) { shape = getRectangle(tmp_button); } else if (tmp_button.getName().equals("polygon") && !resizable) { shape = getPolygon(tmp_button); } else if (tmp_button.getName().equals("paintable")) { paintable = getRectangle(tmp_button); } else if (tmp_button.getName().equals("command")) {
device = new J2SEDevice(); DeviceFactory.setDevice(device); device.init(emulatorContext); } else { try { device = (DeviceImpl) cl.newInstance(); DeviceFactory.setDevice(device); device.init(emulatorContext); } catch (ClassNotFoundException ex) { try { device = DeviceImpl.create(emulatorContext, Main.class.getClassLoader(), deviceParameter, J2SEDevice.class); DeviceFactory.setDevice(device); if (((DeviceDisplayImpl) device.getDeviceDisplay()).isResizable()) { resize(device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight()); } else { resize(device.getNormalImage().getWidth(), device.getNormalImage().getHeight());
urls[0] = deviceInputFile.toURI().toURL(); ClassLoader classLoader = new ExtensionsClassLoader(urls, urls.getClass().getClassLoader()); device = DeviceImpl.create(context, classLoader, descriptorLocation, J2SEDevice.class);
private void parseDisplay(ClassLoader classLoader, String base, XMLElement tmp) throws IOException { DeviceDisplayImpl deviceDisplay = (DeviceDisplayImpl) getDeviceDisplay(); deviceDisplay.setNumColors(Integer.parseInt(tmp_display.getContent())); } else if (tmp_display.getName().equals("iscolor")) { deviceDisplay.setIsColor(parseBoolean(tmp_display.getContent())); } else if (tmp_display.getName().equals("numalphalevels")) { deviceDisplay.setNumAlphaLevels(Integer.parseInt(tmp_display.getContent())); deviceDisplay.setForegroundColor(new Color(Integer.parseInt(tmp_display.getContent(), 16))); } else if (tmp_display.getName().equals("rectangle")) { Rectangle rect = getRectangle(tmp_display); if (deviceDisplay.isResizable()) { rect.x = 0; deviceDisplay.setDisplayPaintable(getRectangle(tmp_display)); .getStringAttribute("name"), getRectangle(tmp_display.getChild("paintable")), loadImage( classLoader, base, tmp_display.getStringAttribute("src")), loadImage(classLoader, base, tmp_display.getStringAttribute("src"))); getSoftButtons().addElement(icon); } else if (tmp_display.getStringAttribute("name").equals("mode")) { deviceDisplay.setMode123Image(new PositionedImage(loadImage(classLoader, base, tmp_display .getStringAttribute("src")), getRectangle(tmp_display.getChild("paintable")))); } else if (tmp_display.getStringAttribute("type").equals("abc")) { deviceDisplay.setModeAbcLowerImage(new PositionedImage(loadImage(classLoader, base, tmp_display .getStringAttribute("src")), getRectangle(tmp_display.getChild("paintable")))); } else if (tmp_display.getStringAttribute("type").equals("ABC")) { deviceDisplay.setModeAbcUpperImage(new PositionedImage(loadImage(classLoader, base, tmp_display
if (deviceDescriptorLocation != null) { try { setDevice(DeviceImpl.create(emulatorContext, classLoader, deviceDescriptorLocation, defaultDeviceClass)); DeviceDisplayImpl deviceDisplay = (DeviceDisplayImpl) DeviceFactory.getDevice().getDeviceDisplay(); if (overrideDeviceWidth != -1 && overrideDeviceHeight != -1) { classLoader = createExtensionsClassLoader(urls); setDevice(DeviceImpl.create(emulatorContext, classLoader, defaultDevice.getDescriptorLocation(), defaultDeviceClass)); defaultDeviceSelected = true; } else { DeviceImpl device = (DeviceImpl) deviceClass.newInstance(); device.init(emulatorContext); setDevice(device);
int width; int height; if (((DeviceDisplayImpl) device.getDeviceDisplay()).isResizable()) { width = device.getDeviceDisplay().getFullWidth(); height = device.getDeviceDisplay().getFullHeight(); } else { width = device.getNormalImage().getWidth(); height = device.getNormalImage().getHeight(); if (device.getDescriptorLocation() != null) { writer.write("\t\t\t<param name=\"device\" value=\"" + device.getDescriptorLocation() + "\">\n");
public static DeviceImpl create(EmulatorContext context, ClassLoader classLoader, String descriptorLocation, Class defaultDeviceClass) throws IOException { XMLElement doc = loadDeviceDescriptor(classLoader, descriptorLocation); device.loadConfig(classLoader, besourceBase(descriptorLocation), doc);
private void parseFonts(ClassLoader classLoader, String base, XMLElement tmp) throws IOException { FontManagerImpl fontManager = (FontManagerImpl) getFontManager(); int defSize = Integer.parseInt(tmp_def.getStringAttribute("size")); fontManager.setFont(face, style, size, fontManager.createTrueTypeFont(getResourceUrl( classLoader, base, defSrc), defStyle, defSize, antialiasing));
private URL getResourceUrl(ClassLoader classLoader, String base, String src) throws IOException { String expandedSource = expandResourcePath(base, src); URL result = classLoader.getResource(expandedSource); if (result == null) { throw new IOException("Cannot find resource: " + expandedSource); } return result; }
String entryName = (String) it.next(); try { devices.put(entryName, DeviceImpl.create(emulatorContext, classLoader, entryName, J2SEDevice.class)); } catch (IOException e) {
Device device = DeviceImpl.create( emulatorContext, classLoader,
/** * @deprecated */ public void init(EmulatorContext context, String config) { super.init(context, config); }
devices.put( entry.getName(), DeviceImpl.create(emulatorContext, classLoader, entry.getName())); } catch (IOException ex) { Message.error("Error parsing device profile, " + Message.getCauseMessage(ex), ex);
/** * @deprecated use Device.create(EmulatorContext context, ClassLoader * classLoader, String descriptorLocation); */ public void init(EmulatorContext context) { init(context, DEFAULT_LOCATION); }
Device device = DeviceImpl.create(emulatorContext, classLoader, entry.getDescriptorLocation(), J2SEDevice.class); this.deviceEntry = entry;