List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:Main.java
/** * gets the center point for "what" relative to the given Dimension dim * @param dim//from ww w . j av a2s . c o m * @param what */ private static Point center(java.awt.Dimension dim, java.awt.Window what) { // Determine the new location of the window int w = what.getSize().width; int h = what.getSize().height; int x = (dim.width - w) / 2; int y = (dim.height - h) / 2; return new Point(x, y); }
From source file:Main.java
/** * This method returns the point at which the incoming dialog will be * perfectly centered on screen.//from w ww .ja v a 2 s . c o m * @param windowToCenter The window to center. Make sure thesize has been set (pack or validate first). * @return The point to set on the dialog using setLocation(). */ public static Point getCenteredWindowPoint(java.awt.Window windowToCenter) { //Center the Dialog Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = windowToCenter.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } Point centerCoord = new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return centerCoord; }
From source file:Main.java
public static Cursor buildCursorByTrimming(Toolkit toolkit, Image image, int x, int y, String name, Cursor defaultCursor) {// ww w . j a v a 2 s . c o m Dimension d = toolkit.getBestCursorSize(image.getWidth(null), image.getHeight(null)); if (d == null || d.getWidth() <= 0 || d.getHeight() <= 0) return defaultCursor; BufferedImage out = new BufferedImage((int) d.getWidth(), (int) d.getHeight(), BufferedImage.TYPE_INT_ARGB); out.getGraphics().drawImage(image, 0, 0, null); return toolkit.createCustomCursor(out, new Point(x, y), name); }
From source file:Main.java
public static Point getRelLocation(Component c) { if (c == null || !c.isShowing()) { return new Point(0, 0); }/*www . j a v a 2s . com*/ Container parent = getRootContainer(c); if ((parent != null) && parent.isShowing()) { Point p1 = c.getLocationOnScreen(); Point p2 = parent.getLocationOnScreen(); return new Point(p1.x - p2.x, p1.y - p2.y); } return new Point(0, 0); }
From source file:st.jigasoft.dbutil.util.ReportTheme.java
public static void circularTheme(JFreeChart chart, String... colunsName) { chart.setBackgroundPaint(// w ww. ja v a 2 s .c o m new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); int iCount = 0; // use gradients and white borders for the section colours for (Object s : colunsName) { plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++))); if (iCount == MAX_COLUNS_COLOR) iCount = 0; } plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); }
From source file:Main.java
public static void setCenter(Component component, Component component1) { Point point;/*from w ww . j a va 2 s. c o m*/ 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 void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(new Point(10, 10)); r.setSize(30, 30);//from w w w. j a va 2s . co m g2.fill(r); System.out.println(r.isEmpty()); }
From source file:Main.java
/** * Returns mouse point relative to specified component. * * @param component//from ww w . j av a 2s. c om * component to process * @return mouse point relative to specified component */ public static Point getMousePoint(final Component component) { final Point p = MouseInfo.getPointerInfo().getLocation(); final Point los = component.getLocationOnScreen(); return new Point(p.x - los.x, p.y - los.y); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(new Point(10, 10), new Dimension(40, 40)); g2.fill(r);//from ww w . j a va 2s. c o m }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(10, 10, 50, 40); r.add(new Point(40, 40)); g2.fill(r);/* w w w .j a v a 2 s.com*/ }