HostApplet.this.displayHost = new DisplayHost(); setLayout(new java.awt.BorderLayout()); add(HostApplet.this.displayHost); displays.add(HostApplet.this.displayHost.getDisplay());
displays.add(primaryDisplayHost.getDisplay()); primaryDisplayHost.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyEvent) {
public DisplayHost() { enableEvents(AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK setFocusTraversalKeysEnabled(false);
displays.add(primaryDisplayHost.getDisplay()); primaryDisplayHost.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyEvent) {
startNativeDrag(dragSource, dragDescendant, event); repaintDragRepresentation(); dropDescendant = getDropDescendant(x, y); setCursor(getDropCursor(dropAction)); repaintDragRepresentation(); repaintDragRepresentation();
startNativeDrag(dragSource, dragDescendant, event); repaintDragRepresentation(); dropDescendant = getDropDescendant(x, y); setCursor(getDropCursor(dropAction)); repaintDragRepresentation(); repaintDragRepresentation();
displayHost = new DisplayHost(); setLayout(new java.awt.BorderLayout()); add(displayHost); displays.add(displayHost.getDisplay());
ApplicationContext.DisplayHost displayHost = display.getDisplayHost(); int cursorID = displayHost.getCursor().getType(); switch (cursorID) { case java.awt.Cursor.DEFAULT_CURSOR: {
ApplicationContext.DisplayHost displayHost = display.getDisplayHost(); int cursorID = displayHost.getCursor().getType(); switch (cursorID) { case java.awt.Cursor.DEFAULT_CURSOR: {
public DisplayHost() { enableEvents(AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK java.awt.dnd.DropTarget dropTarget = new java.awt.dnd.DropTarget(this, dropTargetListener); setFocusTraversalKeysEnabled(false);
&& component.isVisible()) { Display display = (Display)component; graphics = (Graphics2D)display.getDisplayHost().getGraphics(); double scale = display.getDisplayHost().getScale(); if (scale != 1) { graphics.scale(scale, scale);
graphics.clipRect(0, 0, getWidth(), getHeight()); print(graphics); return; boolean bPaintSuccess = false; if (volatileImagePaintEnabled) { bPaintSuccess = paintVolatileBuffered((Graphics2D)graphics); bPaintSuccess = paintBuffered((Graphics2D)graphics); paintDisplay((Graphics2D)graphics); graphics.setColor(new java.awt.Color(random.nextInt(256), random.nextInt(256), random.nextInt(256), 75)); graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.clipRect(0, 0, getWidth(), getHeight()); print(graphics); return; boolean bPaintSuccess = false; if (volatileImagePaintEnabled) { bPaintSuccess = paintVolatileBuffered((Graphics2D)graphics); bPaintSuccess = paintBuffered((Graphics2D)graphics); paintDisplay((Graphics2D)graphics); graphics.setColor(new java.awt.Color(random.nextInt(256), random.nextInt(256), random.nextInt(256), 75)); graphics.fillRect(0, 0, getWidth(), getHeight());
Display display = this.displayHost.getDisplay(); displays.add(display); this.displayHost.requestFocus(); Display display = this.displayHost.getDisplay(); displays.remove(display);
&& component.isVisible()) { Display display = (Display)component; graphics = (Graphics2D)display.getDisplayHost().getGraphics(); double scale = display.getDisplayHost().getScale(); if (scale != 1) { graphics.scale(scale, scale);
@Override public void processWindowEvent(WindowEvent event) { super.processWindowEvent(event); switch(event.getID()) { case WindowEvent.WINDOW_OPENED: { Display display = displayHost.getDisplay(); displays.add(display); if (displayCloseListener != null) { displayCloseListener.hostWindowOpened(display); } displayHost.requestFocus(); break; } case WindowEvent.WINDOW_CLOSING: { dispose(); break; } case WindowEvent.WINDOW_CLOSED: { Display display = displayHost.getDisplay(); displays.remove(display); if (displayCloseListener != null) { displayCloseListener.hostWindowClosed(display); } break; } } } }
@Override public void repaint(int x, int y, int width, int height, boolean immediate) { if (immediate) { Graphics2D graphics = (Graphics2D)displayHost.getGraphics(); // If the display host has been made non-displayable (as will // happen when the native peer closes), graphics will be null if (graphics != null) { double scale = displayHost.getScale(); if (scale == 1) { graphics.clipRect(x, y, width, height); } else { graphics.clipRect((int)Math.floor(x * scale), (int)Math.floor(y * scale), (int)Math.ceil(width * scale) + 1, (int)Math.ceil(height * scale) + 1); } displayHost.paint(graphics); graphics.dispose(); } } else { displayHost.repaint(x, y, width, height); } }
@Override public void repaint(int x, int y, int width, int height, boolean immediate) { if (immediate) { Graphics2D graphics = (Graphics2D)displayHost.getGraphics(); // If the display host has been made non-displayable (as will // happen when the native peer closes), graphics will be null if (graphics != null) { double scale = displayHost.getScale(); if (scale == 1) { graphics.clipRect(x, y, width, height); } else { graphics.clipRect((int)Math.floor(x * scale), (int)Math.floor(y * scale), (int)Math.ceil(width * scale) + 1, (int)Math.ceil(height * scale) + 1); } displayHost.paint(graphics); graphics.dispose(); } } else { displayHost.repaint(x, y, width, height); } }
@Override public void print(Graphics graphics) { // TODO: verify if/how we have to re-scale output in this case ... // Intersect the clip region with the bounds of this component // (for some reason, AWT does not do this automatically) graphics.clipRect(0, 0, getWidth(), getHeight()); java.awt.Rectangle clipBounds = graphics.getClipBounds(); if (clipBounds != null && !clipBounds.isEmpty()) { try { // When printing, there is no point in using offscreen buffers. paintDisplay((Graphics2D)graphics); } catch (RuntimeException exception) { System.err.println("Exception thrown during print(): " + exception); throw exception; } } }
/** * Use this method to scale up or down (that is zoom in or out) * the entire application's display. * <p> For the main application window, a {@link org.apache.pivot.wtk.effects.ScaleDecorator} * cannot be used. This method (and related ones) must be used instead. * @see #scaleUp * @see #scaleDown * @see #getScale */ public void setScale(double scale) { if (scale != this.scale) { this.scale = scale; display.setSize(Math.max((int)Math.ceil(getWidth() / scale), 0), Math.max((int)Math.ceil(getHeight() / scale), 0)); display.repaint(); } }