Search in sources :

Example 31 with Toolkit

use of java.awt.Toolkit in project pivot by apache.

the class Platform method initializeFontRenderContext.

private static void initializeFontRenderContext() {
    Object aaHint = null;
    Object fmHint = null;
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    java.util.Map<?, ?> fontDesktopHints = (java.util.Map<?, ?>) toolkit.getDesktopProperty("awt.font.desktophints");
    if (fontDesktopHints != null) {
        aaHint = fontDesktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
        fmHint = fontDesktopHints.get(RenderingHints.KEY_FRACTIONALMETRICS);
    }
    if (aaHint == null) {
        aaHint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
    }
    if (fmHint == null) {
        fmHint = RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT;
    }
    fontRenderContext = new FontRenderContext(null, aaHint, fmHint);
}
Also used : Toolkit(java.awt.Toolkit) FontRenderContext(java.awt.font.FontRenderContext)

Example 32 with Toolkit

use of java.awt.Toolkit in project pivot by apache.

the class Platform method getMultiClickInterval.

/**
 * @return The system multi-click interval.
 */
public static int getMultiClickInterval() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Integer multiClickInterval = (Integer) toolkit.getDesktopProperty("awt.multiClickInterval");
    if (multiClickInterval == null) {
        multiClickInterval = Integer.valueOf(DEFAULT_MULTI_CLICK_INTERVAL);
    }
    return multiClickInterval.intValue();
}
Also used : Toolkit(java.awt.Toolkit)

Example 33 with Toolkit

use of java.awt.Toolkit in project pivot by apache.

the class LabelAntialiasTest method showFontDesktopHints.

/**
 * Write to console some details of Desktop Hints, for Font Rendering.
 *
 * @see org.apache.pivot.wtk.Platform#initializeFontRenderContext
 */
private void showFontDesktopHints() {
    System.out.println("Show Font Desktop Hints:");
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    java.util.Map<?, ?> fontDesktopHints = (java.util.Map<?, ?>) toolkit.getDesktopProperty("awt.font.desktophints");
    System.out.println(fontDesktopHints);
}
Also used : Toolkit(java.awt.Toolkit) Map(org.apache.pivot.collections.Map)

Example 34 with Toolkit

use of java.awt.Toolkit in project com.revolsys.open by revolsys.

the class Viewport2D method getScreenResolution.

public int getScreenResolution() {
    final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
    final int screenResolution = defaultToolkit.getScreenResolution();
    return 96;
}
Also used : Toolkit(java.awt.Toolkit) Point(com.revolsys.geometry.model.Point)

Example 35 with Toolkit

use of java.awt.Toolkit in project ffx by mjschnie.

the class MainPanel method loadPrefs.

/**
 * Load preferences from the user node
 */
public void loadPrefs() {
    String c = MainPanel.class.getName();
    JFrame frame1 = (JFrame) SwingUtilities.getRoot(this);
    Toolkit toolkit = getToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    int x = preferences.getInt(c + ".x", screenSize.width / 8);
    int y = preferences.getInt(c + ".y", screenSize.height / 8);
    int width = preferences.getInt(c + ".width", screenSize.width * 3 / 4);
    int height = preferences.getInt(c + ".height", screenSize.height * 3 / 4);
    if (width > screenSize.width * 0.4 && width < screenSize.width * 0.8 && height > screenSize.height * 0.4 && height < screenSize.height * 0.8) {
        frame1.setSize(width, height);
    } else {
        frame1.setSize(screenSize.width * 4 / 5, screenSize.height * 4 / 5);
    }
    if (x > 0 && x < screenSize.width / 2 && y > 0 && y < screenSize.height / 2) {
        frame1.setLocation(x, y);
    } else {
        frame1.setLocation(screenSize.width / 8, screenSize.height / 8);
    }
    splitPaneDivider = preferences.getInt(c + ".divider", 200);
    if (splitPaneDivider < frame1.getWidth() * (1.0f / 4.0f)) {
        splitPaneDivider = (int) (frame1.getWidth() * (1.0f / 4.0f));
    }
    splitPane.setDividerLocation(splitPaneDivider);
    if (!preferences.getBoolean(c + ".system", true)) {
        mainMenu.setSystemShowing(false);
        splitPane.setDividerLocation(0);
    } else {
        mainMenu.setSystemShowing(true);
    }
    if (!preferences.getBoolean(c + ".menu", true)) {
        remove(mainMenu.getToolBar());
        mainMenu.setMenuShowing(false);
        validate();
    } else {
        mainMenu.setMenuShowing(true);
    }
    try {
        port = preferences.getInt(c + ".port", 2000);
        ip = preferences.get(c + ".ip", InetAddress.getLocalHost().getHostAddress());
        if (ip != null) {
            address = InetAddress.getByName(ip);
            socketAddress = new InetSocketAddress(address, port);
        } else {
            socketAddress = new InetSocketAddress(port);
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, e.toString());
    }
    if (graphicsCanvas != null) {
        graphicsCanvas.loadPrefs();
    }
}
Also used : JFrame(javax.swing.JFrame) InetSocketAddress(java.net.InetSocketAddress) Toolkit(java.awt.Toolkit) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) Dimension(java.awt.Dimension) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException)

Aggregations

Toolkit (java.awt.Toolkit)93 Dimension (java.awt.Dimension)27 Point (java.awt.Point)20 Image (java.awt.Image)19 BufferedImage (java.awt.image.BufferedImage)14 URL (java.net.URL)14 GraphicsDevice (java.awt.GraphicsDevice)8 GraphicsEnvironment (java.awt.GraphicsEnvironment)7 Insets (java.awt.Insets)7 Rectangle (java.awt.Rectangle)6 IOException (java.io.IOException)6 Field (java.lang.reflect.Field)6 MediaTracker (java.awt.MediaTracker)5 ImageIcon (javax.swing.ImageIcon)5 Frame (java.awt.Frame)4 Clipboard (java.awt.datatransfer.Clipboard)4 Font (java.awt.Font)3 Graphics (java.awt.Graphics)3 GraphicsConfiguration (java.awt.GraphicsConfiguration)3 Method (java.lang.reflect.Method)3