private Dimension getDeviceDimension() { Dimension deviceDimension = null; try { Toolkit tool = Toolkit.getDefaultToolkit(); deviceDimension = tool.getScreenSize(); } catch (AWTError e) { System.out.println(CLASS_NAME+": ERROR! "+ e.getMessage()); e.printStackTrace(); } return deviceDimension; }
/** * Lays out the specified container using this layout. * * @param parent The container that needs to be laid out. */ public void layoutContainer(Container parent) { synchronized (container.getTreeLock()) { if (container != parent) throw new AWTError("BoxLayout can't be shared"); checkLayout(); Component[] children = container.getComponents(); Insets in = container.getInsets(); for (int i = 0; i < children.length; i++) children[i].setBounds(offsetsX[i] + in.left, offsetsY[i] + in.top, spansX[i], spansY[i]); } }
/** * Invalidates the layout. * * @param parent The container that needs to be laid out. */ public void invalidateLayout(Container parent) { if (container != parent) throw new AWTError("BoxLayout can't be shared"); synchronized (container.getTreeLock()) { xChildren = null; yChildren = null; xTotal = null; yTotal = null; offsetsX = null; offsetsY = null; spansX = null; spansY = null; } }
/** * Returns the maximum size of the layout gived the components * in the given container. * * @param parent The container that needs to be laid out. * * @return The dimension of the layout. */ public Dimension maximumLayoutSize(Container parent) { synchronized (container.getTreeLock()) { if (container != parent) throw new AWTError("BoxLayout can't be shared"); checkTotalRequirements(); Insets i = container.getInsets(); int xDim = xTotal.maximum + i.left + i.right; int yDim = yTotal.maximum + i.top + i.bottom; // Check for overflow if (xDim < xTotal.maximum) xDim = Integer.MAX_VALUE; if (yDim < yTotal.maximum) yDim = Integer.MAX_VALUE; return new Dimension(xDim, yDim); } }
/** * Initializes the font peer with the specified attributes. This method is * called from both constructors. * * @param name the font name * @param style the font style * @param size the font size */ private void init(String name, int style, int size) { if (name == null) { name = "SansSerif"; } GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice dev = env.getDefaultScreenDevice(); if (dev instanceof XGraphicsDevice) { Display display = ((XGraphicsDevice) dev).getDisplay(); String fontDescr = encodeFont(name, style, size); if (XToolkit.DEBUG) System.err.println("XLFD font description: " + fontDescr); xfont = new gnu.x11.Font(display, fontDescr); } else { throw new AWTError("Local GraphicsEnvironment is not XWindowGraphicsEnvironment"); } }
private int axisToAlignment(final Container target, final int axis) throws AWTError { int alignment = LayoutParameters.HORIZONTAL_ALIGNMENT; if (axis == X_AXIS) { alignment = LayoutParameters.HORIZONTAL_ALIGNMENT; } else if (axis == Y_AXIS) { alignment = LayoutParameters.VERTICAL_ALIGNMENT; } else if (axis == LINE_AXIS) { if (target != null) { alignment = target.getComponentOrientation().isHorizontal() ? LayoutParameters.HORIZONTAL_ALIGNMENT : LayoutParameters.VERTICAL_ALIGNMENT; } } else if (axis == PAGE_AXIS) { if (target != null) { alignment = target.getComponentOrientation().isHorizontal() ? LayoutParameters.VERTICAL_ALIGNMENT : LayoutParameters.HORIZONTAL_ALIGNMENT; } } else { throw new AWTError(Messages.getString("swing.err.04")); //$NON-NLS-1$ } return alignment; }
public FreetypeFontPeer(String name, Map<?, ?> attrs) { super(name, attrs); nativefont = createfont(); System.out.println("native font: "+nativefont); if(nativefont == 0){ throw new AWTError("errorr while allocating memory for freetype font"); } int error = initFont(nativefont, "/system/fonts/DroidSans.ttf"); System.out.println("init font error code "+error); if(error != 0){ throw new AWTError("an error occurred during font initialization: error code " + error); } error = setsize(nativefont, (int) this.size); System.out.println("resize error code "+error); if(error != 0){ throw new AWTError("an error occurred during font resize: error code " + error); } }
/** * Returns the default screen graphics device. */ public GraphicsDevice getDefaultScreenDevice() { GraphicsDevice[] screens = getScreenDevices(); if (screens.length == 0) { throw new AWTError("no screen devices"); } return screens[0]; }
public GraphicsDevice getDefaultScreenDevice() { GraphicsDevice[] screens = getScreenDevices(); if (screens.length == 0) { throw new AWTError("no screen devices"); } int index = getDefaultScreen(); return screens[0 < index && index < screens.length ? index : 0]; }
/** * Returns the default screen graphics device. */ public GraphicsDevice getDefaultScreenDevice() { GraphicsDevice[] screens = getScreenDevices(); if (screens.length == 0) { throw new AWTError("no screen devices"); } int index = getDefaultScreenNum(); return screens[0 < index && index < screens.length ? index : 0]; }
public static void executeOnAppKit(Runnable command) { if (!isAppKit()) { Dispatch dispatch = Dispatch.getInstance(); if (dispatch != null) { dispatch.getNonBlockingMainQueueExecutor().execute(command); } else { throw new AWTError("Could not get Dispatch object"); } } else command.run(); }