Example usage for java.awt GraphicsConfigTemplate PREFERRED

List of usage examples for java.awt GraphicsConfigTemplate PREFERRED

Introduction

In this page you can find the example usage for java.awt GraphicsConfigTemplate PREFERRED.

Prototype

int PREFERRED

To view the source code for java.awt GraphicsConfigTemplate PREFERRED.

Click Source Link

Document

Value used for "Enum" (Integer) type.

Usage

From source file:MixedTest.java

protected Canvas3D createCanvas3D() {
    // overidden this method to create a custom
    // Canvas3D that will implement the Immediate Mode rendering
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    ImmediateCanvas3D c3d = new ImmediateCanvas3D(gd[0].getBestConfiguration(gc3D));
    c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d));

    return (Canvas3D) c3d;
}

From source file:RasterTest.java

protected Canvas3D createCanvas3D() {
    // create a custom Canvas3D with postSwap overidden
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    RasterCanvas3D c3d = new RasterCanvas3D(this, gd[0].getBestConfiguration(gc3D));
    c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d));

    return c3d;//www .  j a  v a  2 s.  co m
}

From source file:SwingTest.java

/**
 * Create a Canvas3D./*  w ww.ja  va  2 s  .co  m*/
 * 
 * @param offscreen
 *            true to specify an offscreen canvas
 */
protected Canvas3D createCanvas3D(boolean offscreen) {
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D), offscreen);
    c3d.setSize(500, 500);

    return c3d;
}

From source file:MixedTest.java

protected Canvas3D createCanvas3D() {
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D));
    c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d));

    return c3d;//from w w w .j  av  a  2  s  .  co  m
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>/*w  w w .j  ava  2  s.  co  m*/
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir",
            FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2,
                (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template3D);
        graphicsCanvas = new GraphicsCanvas(gc, this);
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();

    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);

    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
     treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}