use of java.awt.GraphicsConfiguration in project ffx by mjschnie.
the class MainPanel method initialize.
/**
* <p>
* 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 = null;
try {
gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template3D);
// gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
} catch (Exception e) {
e.fillInStackTrace();
e.printStackTrace();
logger.log(Level.SEVERE, " Exception encountered when trying to get the best GraphicsConfiguration", e);
}
try {
graphicsCanvas = new GraphicsCanvas(gc, this);
} catch (Exception e) {
e.fillInStackTrace();
e.printStackTrace();
logger.log(Level.SEVERE, " Exception encountered when trying to create the GraphicsCanvas", e);
}
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();
}
}
use of java.awt.GraphicsConfiguration in project jmulticard by ctt-gob-es.
the class ResizingAdaptor method iconToImage.
private static Image iconToImage(final Icon icon, final Dimension d) {
if (icon instanceof ImageIcon) {
return ((ImageIcon) icon).getImage();
}
final int w = d.width;
final int h = d.height;
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice gd = ge.getDefaultScreenDevice();
final GraphicsConfiguration gc = gd.getDefaultConfiguration();
final BufferedImage image = gc.createCompatibleImage(w, h);
final Graphics2D g = image.createGraphics();
icon.paintIcon(null, g, 0, 0);
g.dispose();
return image;
}
use of java.awt.GraphicsConfiguration in project darkFunction-Editor by darkFunction.
the class AnimationCell method draw.
public void draw(final Graphics g, final Rectangle destRect) {
if (vImage == null)
return;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
int valid = vImage.validate(gc);
if (valid == VolatileImage.IMAGE_INCOMPATIBLE) {
rebuild();
}
if (vImage != null) {
Rectangle r = destRect;
g.drawImage(vImage, r.x, r.y, r.width, r.height, null);
}
}
use of java.awt.GraphicsConfiguration in project darkFunction-Editor by darkFunction.
the class ImageUtil method createVolatileImage.
public static VolatileImage createVolatileImage(int width, int height, int transparency) {
if (width == 0 || height == 0)
return null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage image = null;
image = gc.createCompatibleVolatileImage(width, height, transparency);
int valid = image.validate(gc);
if (valid == VolatileImage.IMAGE_INCOMPATIBLE) {
image = createVolatileImage(width, height, transparency);
}
return image;
}
use of java.awt.GraphicsConfiguration in project darkFunction-Editor by darkFunction.
the class ImageUtil method createVolatileImage.
public static VolatileImage createVolatileImage(BufferedImage bi) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage vimage = createVolatileImage(bi.getWidth(), bi.getHeight(), java.awt.Transparency.TRANSLUCENT);
java.awt.Graphics2D g = null;
try {
g = vimage.createGraphics();
// clear to transparent
g.setComposite(AlphaComposite.Src);
g.setColor(new Color(0, 0, 0, 0));
g.fillRect(0, 0, vimage.getWidth(), vimage.getHeight());
g.drawImage(bi, null, 0, 0);
} finally {
g.dispose();
}
return vimage;
}
Aggregations