List of usage examples for java.awt Point Point
public Point()
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 ava 2 s . com } 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
private static double extractAngle(AffineTransform at) { Point2D p0 = new Point(); Point2D p1 = new Point(1, 0); Point2D pp0 = at.transform(p0, null); Point2D pp1 = at.transform(p1, null); double dx = pp1.getX() - pp0.getX(); double dy = pp1.getY() - pp0.getY(); double angle = Math.atan2(dy, dx); return angle; }
From source file:Main.java
public static MouseEvent adaptEventToDescendent(MouseEvent e, JComponent descendentTarget) { Point trans = new Point(); Component source = e.getComponent(); Component current = descendentTarget; while (current != source) { Rectangle b = current.getBounds(); trans.x += b.x;// w w w.jav a 2s.c o m trans.y += b.y; current = current.getParent(); } Point point = e.getPoint(); return new MouseEvent(descendentTarget, e.getID(), e.getWhen(), e.getModifiers(), point.x + trans.x, point.y + trans.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()); }
From source file:Main.java
public Main(JFrame frame) { this.frame = frame; cursor = new Point(); this.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { cursor = new Point(evt.getPoint()); Main.this.repaint(); }//from w w w.j a v a2s . com }); this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { Main.this.setVisible(false); } }); }
From source file:Main.java
ScreenCaptureRectangle(final BufferedImage screen) { BufferedImage screenCopy = new BufferedImage(screen.getWidth(), screen.getHeight(), screen.getType()); JLabel screenLabel = new JLabel(new ImageIcon(screenCopy)); JScrollPane screenScroll = new JScrollPane(screenLabel); screenScroll.setPreferredSize(new Dimension(300, 300)); repaint(screen, screenCopy);//from ww w . jav a2s . com screenLabel.repaint(); screenLabel.addMouseMotionListener(new MouseMotionAdapter() { Point start = new Point(); @Override public void mouseMoved(MouseEvent me) { start = me.getPoint(); repaint(screen, screenCopy); screenLabel.repaint(); } @Override public void mouseDragged(MouseEvent me) { Point end = me.getPoint(); captureRect = new Rectangle(start, new Dimension(end.x - start.x, end.y - start.y)); repaint(screen, screenCopy); screenLabel.repaint(); } }); JOptionPane.showMessageDialog(null, screenScroll); }
From source file:Main.java
/** * Calculates the position of a frame to be in the center of an other frame. * * @param parentFrame/*from w ww. ja va 2s . co m*/ * @param frame * @return */ public static Point getCenter(final Component parentFrame, final Window frame) { final Point point = new Point(); int x = 0, y = 0; if (parentFrame == null || frame == null) { point.setLocation(x, y); return point; } x = parentFrame.getLocation().x + parentFrame.getSize().width / 2 - frame.getSize().width / 2; y = parentFrame.getLocation().y + parentFrame.getSize().height / 2 - frame.getSize().height / 2; point.setLocation(x, y); return point; }
From source file:motordrivertxrx.View.MainView.java
/** * Creates new form MainView/*from w w w . j av a 2 s. c o m*/ */ public MainView() { initComponents(); this.dataset1 = new DefaultValueDataset(10.0); this.dataset2 = new DefaultValueDataset(50.0); // get data for diagrams DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, this.dataset1); plot.setDataset(1, this.dataset2); SimpleDialFrame dialFrame = new SimpleDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.DARK_GRAY); plot.setDialFrame(dialFrame); /* GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); */ GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), Color.ORANGE); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setBackground(db); DialTextAnnotation annotation1 = new DialTextAnnotation("Velocidad"); annotation1.setFont(new Font("Dialog", Font.BOLD, 14)); annotation1.setRadius(0.7); plot.addLayer(annotation1); DialValueIndicator dvi = new DialValueIndicator(0, "c"); dvi.setFont(new Font("Dialog", Font.PLAIN, 10)); dvi.setOutlinePaint(Color.darkGray); dvi.setRadius(0.60); dvi.setAngle(-103.0); plot.addLayer(dvi); DialValueIndicator dvi2 = new DialValueIndicator(1, "c"); dvi2.setFont(new Font("Dialog", Font.PLAIN, 10)); dvi2.setOutlinePaint(Color.red); dvi2.setRadius(0.60); dvi2.setAngle(-77.0); plot.addLayer(dvi2); StandardDialScale scale = new StandardDialScale(0, 127, -120, -300); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 14)); plot.addScale(0, scale); StandardDialScale scale2 = new StandardDialScale(0, 100, -120, -300); scale2.setTickRadius(0.50); scale2.setTickLabelOffset(0.15); scale2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); scale2.setMajorTickPaint(Color.red); plot.addScale(1, scale2); plot.mapDatasetToScale(1, 1); DialPointer needle2 = new DialPointer.Pin(1); needle2.setRadius(0.55); plot.addLayer(needle2); DialPointer needle = new DialPointer.Pointer(0); plot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); JFreeChart chart1 = new JFreeChart(plot); chart1.setTitle("Velocidad motor"); ChartPanel cp1 = new ChartPanel(chart1); cp1.setPreferredSize(new Dimension(400, 400)); /*JPanel sliderPanel = new JPanel(new GridLayout(2, 2)); sliderPanel.add(new JLabel("Outer Needle:")); sliderPanel.add(new JLabel("Inner Needle:")); this.slider1 = new JSlider(-40, 60); this.slider1.setMajorTickSpacing(20); this.slider1.setPaintTicks(true); this.slider1.setPaintLabels(true); this.slider1.addChangeListener(this); sliderPanel.add(this.slider1); sliderPanel.add(this.slider1); this.slider2 = new JSlider(0, 100); this.slider2.setMajorTickSpacing(20); this.slider2.setPaintTicks(true); this.slider2.setPaintLabels(true); this.slider2.addChangeListener(this); sliderPanel.add(this.slider2);*/ velocimetroPanel.add(cp1); }
From source file:netplot.DialPlotPanel.java
public void init() { finalize();//ww w . jav a 2 s. co m this.dataset1 = new DefaultValueDataset(10.0); this.dataset2 = new DefaultValueDataset(50.0); // get data for diagrams plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, this.dataset1); plot.setDataset(1, this.dataset2); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.darkGray); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); plot.setBackground(db); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); chart = new JFreeChart(plot); ChartPanel cp1 = new ChartPanel(chart); cp1.setPreferredSize(new Dimension(400, 400)); add(cp1); }
From source file:com.romraider.logger.ecu.ui.handler.dash.SmallDialGaugeStyle.java
protected JFreeChart buildChart() { DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0);/*from www . j a v a2s . c o m*/ plot.setDataset(0, current); plot.setDataset(1, max); plot.setDataset(2, min); DialFrame dialFrame = new StandardDialFrame(); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL)); plot.setBackground(db); unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 14)); unitsLabel.setRadius(0.7); unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits()); plot.addLayer(unitsLabel); DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat()); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setNumberFormat(format); plot.addLayer(dvi); EcuDataConvertor convertor = loggerData.getSelectedConvertor(); GaugeMinMax minMax = convertor.getGaugeMinMax(); StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12)); scale.setTickLabelFormatter(format); plot.addScale(0, scale); plot.addScale(1, scale); plot.addScale(2, scale); StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED); range.setInnerRadius(0.52); range.setOuterRadius(0.55); plot.addLayer(range); StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE); range2.setInnerRadius(0.52); range2.setOuterRadius(0.55); plot.addLayer(range2); StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN); range3.setInnerRadius(0.52); range3.setOuterRadius(0.55); plot.addLayer(range3); DialPointer needleCurrent = new DialPointer.Pointer(0); plot.addLayer(needleCurrent); DialPointer needleMax = new DialPointer.Pin(1); needleMax.setRadius(0.84); ((DialPointer.Pin) needleMax).setPaint(RED); ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMax); DialPointer needleMin = new DialPointer.Pin(2); needleMin.setRadius(0.84); ((DialPointer.Pin) needleMin).setPaint(BLUE); ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F)); plot.addLayer(needleMin); DialCap cap = new DialCap(); cap.setRadius(0.10); plot.setCap(cap); JFreeChart chart = new JFreeChart(plot); chart.setTitle(loggerData.getName()); return chart; }
From source file:it.marcoberri.mbmeteo.action.chart.GetLastRDial.java
/** * Processes requests for both HTTP/*from ww w . j av a2 s.com*/ * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("start : " + this.getClass().getName()); final HashMap<String, String> params = getParams(request.getParameterMap()); final Integer dimy = Default.toInteger(params.get("dimy"), 600); final Integer dimx = Default.toInteger(params.get("dimx"), 800); Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get(); DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getDayRainfall()); // get data for diagrams DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, dataset); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220)); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); plot.setBackground(db); StandardDialScale scale = new StandardDialScale(); scale.setLowerBound(0); scale.setUpperBound(50); scale.setTickLabelOffset(0.14); scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); plot.addScale(0, scale); DialPointer needle = new DialPointer.Pointer(0); plot.addLayer(needle); JFreeChart chart1 = new JFreeChart(plot); chart1.setTitle("Daily Rain mm"); final File f = File.createTempFile("mbmeteo", ".jpg"); ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy); response.setContentType("image/jpeg"); response.setHeader("Content-Length", "" + f.length()); response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\""); final OutputStream out = response.getOutputStream(); final FileInputStream in = new FileInputStream(f.toString()); final int size = in.available(); final byte[] content = new byte[size]; in.read(content); out.write(content); in.close(); out.close(); }