List of usage examples for java.awt Dimension getHeight
public double getHeight()
From source file:org.swiftexplorer.SwiftExplorer.java
private static void openMainWindow(final MainPanel cp) throws IOException { JFrame frame = new JFrame(Configuration.INSTANCE.getAppName()); Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); float ratio = (float) 0.8; Dimension windowSize = new Dimension((int) (screenSize.getWidth() * ratio), (int) (screenSize.getHeight() * ratio)); frame.setSize(windowSize.getSize()); frame.setLocationByPlatform(true);//from w w w . ja v a2 s. c o m frame.setIconImage(ImageIO.read(SwiftExplorer.class.getResource("/icons/logo.png"))); frame.getContentPane().add(cp); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (cp.onClose()) { System.exit(0); } } }); cp.setOwner(frame); frame.setJMenuBar(cp.createMenuBar()); // center the frame int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); frame.setVisible(true); }
From source file:org.nekorp.workflow.desktop.servicio.imp.ImageServiceImp.java
public static Dimension getScaledDimension(Dimension imgDimension, Dimension boundary) { double width; double height; if (imgDimension.getWidth() > boundary.getWidth()) { width = boundary.getWidth();/* www . j ava 2 s.c o m*/ height = (width * imgDimension.getHeight()) / imgDimension.getWidth(); if (!(height > boundary.getHeight())) { return new Dimension((int) width, (int) height); } } if (imgDimension.getHeight() > boundary.getHeight()) { height = boundary.getHeight(); width = (height * imgDimension.getWidth()) / imgDimension.getHeight(); return new Dimension((int) width, (int) height); } return new Dimension((int) imgDimension.getWidth(), (int) imgDimension.getHeight()); }
From source file:org.fao.geonet.services.region.GetMap.java
public static AffineTransform worldToScreenTransform(Envelope mapExtent, Dimension screenSize) { double scaleX = screenSize.getWidth() / mapExtent.getWidth(); double scaleY = screenSize.getHeight() / mapExtent.getHeight(); double tx = -mapExtent.getMinX() * scaleX; double ty = (mapExtent.getMinY() * scaleY) + screenSize.getHeight(); AffineTransform at = new AffineTransform(scaleX, 0.0d, 0.0d, -scaleY, tx, ty); return at;/*from ww w.j a va 2 s.c o m*/ }
From source file:ro.nextreports.designer.util.ImageUtil.java
public static void drawImage(String imageName, boolean withShadow, Graphics2D g2, int x, int y) { BufferedImage img = toBufferedImage(getImage(imageName)); g2.drawImage(img, null, x, y);//from w ww . j a v a 2s. co m if (withShadow) { BufferedImage shadow = createDropShadow(img); if (shadow != null) { Dimension d = ImageUtil.computeShadowPosition(30, 5); g2.drawImage(shadow, x + (int) d.getWidth(), y + (int) d.getHeight(), null); } } }
From source file:org.xsystem.sql2.http.impl.ImgHelper.java
public static void resaize(String format, int IMG_SIZE, InputStream sorce, OutputStream target) throws IOException { BufferedImage originalImage = ImageIO.read(sorce); int type = format.equalsIgnoreCase("gif") || (originalImage.getType() == 0) ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();/* w w w . j a va 2 s. c o m*/ Dimension new_dim = //new Dimension(IMG_SIZE, IMG_SIZE); getScaledDimension(new Dimension(originalImage.getWidth(), originalImage.getHeight()), new Dimension(IMG_SIZE, IMG_SIZE)); BufferedImage resizedImage = new BufferedImage((int) new_dim.getWidth(), (int) new_dim.getHeight(), type); Graphics2D g2 = resizedImage.createGraphics(); g2.drawImage(originalImage, 0, 0, (int) new_dim.getWidth(), (int) new_dim.getHeight(), null); g2.dispose(); ImageIO.write(resizedImage, format, target); }
From source file:org.processmining.analysis.performance.fsmevaluator.FSMEvaluationMenuUI.java
protected static JPanel packHorizontallyLeftAligned(Component[] components, int leftOffset) { JPanel packed = new JPanel(); packed.setOpaque(false);//from w w w. j a v a 2 s. c o m packed.setLayout(new BoxLayout(packed, BoxLayout.X_AXIS)); if (leftOffset > 0) { packed.add(Box.createHorizontalStrut(leftOffset)); } int minW = 0, minH = 0; for (Component comp : components) { packed.add(comp); Dimension dim = comp.getMinimumSize(); minW += dim.getWidth(); minH = Math.max(minH, (int) dim.getHeight()); } packed.add(Box.createHorizontalGlue()); packed.setMinimumSize(new Dimension(minW, minH)); packed.setMaximumSize(new Dimension(4000, minH)); packed.setPreferredSize(new Dimension(4000, minH)); return packed; }
From source file:be.fedict.eid.applet.maven.DocbookMojo.java
private static void graphToFile(BasicVisualizationServer<String, String> visualization, File file) throws IOException { Dimension size = visualization.getSize(); int width = (int) (size.getWidth() + 1); int height = (int) (size.getHeight() + 1); BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bufferedImage.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, 900, 650);/*from w ww. j a v a 2s. com*/ visualization.setBounds(0, 0, 900, 650); visualization.paint(graphics); graphics.dispose(); ImageIO.write(bufferedImage, "png", file); }
From source file:Main.java
public static void setCenter(Component component, Component component1) { Point point;/* ww w . ja v a2 s . c om*/ Dimension dimension; if (component != null) { point = component.getLocation(); dimension = component.getSize(); } else { dimension = Toolkit.getDefaultToolkit().getScreenSize(); point = new Point(0, 0); } Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize(); point.setLocation((double) point.x + dimension.getWidth() / 2D, (double) point.y + dimension.getHeight() / 2D); Point point1 = new Point(point.x - component1.getWidth() / 2, point.y - component1.getHeight() / 2); if (point1.y < 0) point1.y = 0; if (point1.x < 0) point1.y = 0; if (point1.x + component1.getWidth() > dimension1.width) point1.x = dimension1.width - component1.getWidth(); if (point1.y + component1.getHeight() > dimension1.height) point1.y = dimension1.height - component1.getHeight(); component1.setLocation(point1); }
From source file:Main.java
public static Point getScreenCenterLocation(Window w) { Dimension size = w.getSize(); Toolkit toolkit = Toolkit.getDefaultToolkit(); double desktopHeight = toolkit.getScreenSize().getHeight(); double desktopWidth = toolkit.getScreenSize().getWidth(); // To the left (hack for Ngoc's dual display) if (desktopWidth > 1600) { desktopWidth += 1600;//from w ww. j av a 2 s .c o m } Point location = new Point(); location.x = (int) (desktopWidth - size.getWidth()) / 2; location.y = (int) (desktopHeight - size.getHeight()) / 2; return location; }
From source file:Main.java
/** * Zentriert ein Window relativ zu dem Parent-Window * //from w w w . java 2 s .c o m * @param parent * Parent-Window, wenn null, dann wird relativ zu dem Bildschirm * zentriert * @param child * Window das zentrirt werden soll. */ static public void centreWindow(Window parent, Window child) { if (child == null) return; Point parentLocation = null; Dimension parentSize = null; if (parent == null) { parentLocation = new Point(0, 0); parentSize = child.getToolkit().getScreenSize(); } else { parentLocation = parent.getLocationOnScreen(); parentSize = parent.getSize(); } Dimension childSize = child.getSize(); child.setLocation((int) (parentLocation.getX() + parentSize.getWidth() / 2 - childSize.getWidth() / 2), (int) (parentLocation.getY() + parentSize.getHeight() / 2 - childSize.getHeight() / 2)); }