List of usage examples for java.awt Point Point
public Point()
From source file:CompassButtons.java
public CompassScroller(JViewport viewport) { this.viewport = viewport; p = new Point(); }
From source file:SwingUtil.java
/** * Get the point on point on the screen at which to open a dialog * or window for it to appear centered. This point is the top right hand * corner of the container you want to position. * * * @param size// w w w . ja v a 2 s .c o m * The demensions of the dialog or window to position. * * @return * The top left hand point at which to position the container * for it to appear centered. * */ public static Point getCenteringPoint(Dimension size) { Point centeringPoint = new Point(); Dimension screenSize; screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (size.height > screenSize.height) { size.height = screenSize.height; } if (size.width > screenSize.width) { size.width = screenSize.width; } centeringPoint.x = (screenSize.width - size.width) / 2; centeringPoint.y = (screenSize.height - size.height) / 2; return centeringPoint; }
From source file:com.nbt.TileCanvas.java
private void updateXYZ() { Point pt = getMousePosition(); if (pt == null) pt = new Point(); int x = getTileX() + pixelsToTile(pt.x); int z = getTileZ() + pixelsToTile(pt.y); hud.xl.setText("X: " + x); hud.zl.setText("Z: " + z); hud.al.setText("Y: " + getAltitude()); }
From source file:org.pentaho.chart.plugin.jfreechart.chart.dial.JFreeDialChartGenerator.java
protected void setDialBackground(ChartDocument chartDocument, DialPlot dialPlot) { ChartElement plotElement = getUniqueElement(chartDocument, ChartElement.TAG_NAME_PLOT); CSSValuePair cssValue = (CSSValuePair) plotElement.getLayoutStyle().getValue(ChartStyleKeys.GRADIENT_COLOR); Color beginColor = JFreeChartUtils.getColorFromCSSValue(cssValue.getFirstValue()); Color endColor = JFreeChartUtils.getColorFromCSSValue(cssValue.getSecondValue()); GradientPaint gradientpaint = new GradientPaint(new Point(), beginColor, new Point(), endColor); DialBackground dialbackground = new DialBackground(gradientpaint); // specify Color here for no gradient dialbackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); dialPlot.setBackground(dialbackground); }
From source file:edmondskarp.Controller.EdmondsKarpController.java
public void openState(String s) throws JSONException { if (s == null || s.equals("")) { graph.clearGraph();//from w w w . j ava2 s . c o m gui.getCircles().clear(); name = 0; gui.update(); return; } Map<String, Circle> circles = new HashMap<>(); graph.clearGraph(); int maxIndex = 0; JSONObject jNodeEdge = new JSONObject(s); // Parse the JSON to a JSONObject JSONArray jNodes = jNodeEdge.getJSONArray("Node"); JSONArray jEdges = jNodeEdge.getJSONArray("Edge"); for (int i = 0; i < jNodes.length(); i++) { // Loop over each each row of node Circle circle = new Circle(); Point point = new Point(); JSONObject jNode = jNodes.getJSONObject(i); point.setLocation(jNode.getInt("PosX"), jNode.getInt("PosY")); circle.setFirstPoint(point); circle.addNode(graph.addNode("" + jNode.getString("ID"))); circles.put(jNode.getString("ID"), circle); if (jNode.getInt("ID") > maxIndex) { maxIndex = jNode.getInt("ID"); } } name = ++maxIndex; for (int i = 0; i < jEdges.length(); i++) { // Loop over each each row of edge JSONObject jEdge = jEdges.getJSONObject(i); Edge e = graph.connect(jEdge.getString("From"), jEdge.getString("To"), jEdge.getInt("Capacity"), 0); if (e == null) { graph.checkInverseArrowConnection(jEdge.getString("From"), jEdge.getString("To"), jEdge.getInt("Capacity")); } else { Arrow arrow = new Arrow(circles.get(jEdge.getString("From")), circles.get(jEdge.getString("To"))); arrow.setEdge(e); circles.get(jEdge.getString("From")).addArrowFrom(arrow); circles.get(jEdge.getString("To")).addArrowTo(arrow); } } if (!jNodeEdge.getString("Source").equals("")) { graph.setSource(graph.getNode(jNodeEdge.getString("Source"))); } if (!jNodeEdge.getString("Sink").equals("")) { graph.setSink(graph.getNode(jNodeEdge.getString("Sink"))); } gui.setCircles(new ArrayList(circles.values())); gui.update(); System.gc(); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SimpleDial.java
/** * Creates the chart ./*www.java 2s. c om*/ * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart . */ public JFreeChart createChart(DatasetMap datasets) { // get data for diagrams logger.debug("IN"); Dataset dataset = (Dataset) datasets.getDatasets().get("1"); DialPlot plot = new DialPlot(); plot.setDataset((ValueDataset) dataset); ArcDialFrame dialFrame = null; if (!horizontalView) { plot.setView(0.78, 0.37, 0.22, 0.26); dialFrame = new ArcDialFrame(-10.0, 20.0); } else { plot.setView(0.21, 0.0, 0.58, 0.30); dialFrame = new ArcDialFrame(60.0, 60.0); } dialFrame.setInnerRadius(0.65); dialFrame.setOuterRadius(0.90); dialFrame.setForegroundPaint(Color.darkGray); dialFrame.setStroke(new BasicStroke(3.0f)); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240)); DialBackground sdb = new DialBackground(gp); GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.VERTICAL; if (horizontalView) { gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL; } sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType)); plot.addLayer(sdb); if (!(increment > 0)) { logger.warn("increment cannot be less than 0, put default to 0.1 "); increment = 0.1; } StandardDialScale scale = null; if (!horizontalView) { scale = new StandardDialScale(lower, upper, -8, 16.0, increment, minorTickCount); } else { scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount); } // sets intervals for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(), interval.getColor()); range.setInnerRadius(0.70); range.setOuterRadius(0.75); plot.addLayer(range); } scale.setTickRadius(0.88); scale.setTickLabelOffset(0.07); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); scale.setTickLabelFont(tickLabelsFont); scale.setTickLabelPaint(labelsTickStyle.getColor()); //scale.setMajorTickIncrement(25.0); plot.addScale(0, scale); DialPointer needle = new DialPointer.Pin(); needle.setRadius(0.82); plot.addLayer(needle); DialValueIndicator dvi = new DialValueIndicator(0); dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); dvi.setPaint(labelsValueStyle.getColor()); plot.addLayer(dvi); JFreeChart chart1 = new JFreeChart(plot); chart1.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart1.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart1.addSubtitle(subTitle); } logger.debug("OUT"); return chart1; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SBISpeedometer.java
/** * Creates a chart of type speedometer.// ww w . ja va 2 s . c o m * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart speedometer. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); Dataset dataset = (Dataset) datasets.getDatasets().get("1"); DialPlot plot = new DialPlot(); plot.setDataset((ValueDataset) dataset); plot.setDialFrame(new StandardDialFrame()); plot.setBackground(new DialBackground()); if (dialtextuse) { DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext); annotation1.setFont(styleTitle.getFont()); annotation1.setRadius(0.7); plot.addLayer(annotation1); } DialValueIndicator dvi = new DialValueIndicator(0); dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); dvi.setPaint(labelsValueStyle.getColor()); plot.addLayer(dvi); StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4); if (!(increment > 0)) { logger.warn("increment cannot be less than 0, put default to 0.1"); increment = 0.01; } scale.setMajorTickIncrement(increment); // if (!( minorTickCount > 0)){ // logger.warn("minor tick count cannot be less than 0, put default to 1"); // minorTickCount = 1; // } scale.setMinorTickCount(minorTickCount); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); scale.setTickLabelFont(tickLabelsFont); scale.setTickLabelPaint(labelsTickStyle.getColor()); plot.addScale(0, scale); plot.addPointer(new DialPointer.Pin()); DialCap cap = new DialCap(); plot.setCap(cap); // sets intervals for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(), interval.getColor()); range.setInnerRadius(0.52); range.setOuterRadius(0.55); plot.addLayer(range); } 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); plot.removePointer(0); DialPointer.Pointer p = new DialPointer.Pointer(); p.setFillPaint(Color.yellow); plot.addPointer(p); logger.debug("OUT"); JFreeChart chart = new JFreeChart(name, plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.setBackgroundPaint(color); return chart; }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Gets back the point location where the frame was last saved. * * @return location where the frame was last saved *//*from www .j a v a 2 s .com*/ protected Point loadLastFrameLocation() { Preferences preferences = Preferences.userNodeForPackage(this.getClass()); Point windowLocation = new Point(); windowLocation.setLocation(preferences.getDouble(FRAME_X_LOCATION, 0), preferences.getDouble(FRAME_Y_LOCATION, 0)); return windowLocation; }
From source file:Filter3dTest.java
/** * Creates a new InputManager that listens to input from the specified * component./*from w w w. j av a 2s .com*/ */ public InputManager(Component comp) { this.comp = comp; mouseLocation = new Point(); centerLocation = new Point(); // register key and mouse listeners comp.addKeyListener(this); comp.addMouseListener(this); comp.addMouseMotionListener(this); comp.addMouseWheelListener(this); // allow input of the TAB key and other keys normally // used for focus traversal comp.setFocusTraversalKeysEnabled(false); }
From source file:Creator.WidgetPanel.java
public void buttonClick(Point p, String buttonName, int buttonX, int buttonWidth) { Point np = new Point(); if (buttonName.startsWith("Rack")) { // Rack/*w ww .ja va 2 s.co m*/ np.x = buttonX + 10; np.y = p.y + 6; //np.y = p.y + } else if (buttonName.startsWith("Load")) { // Load np.x = buttonX + 10; np.y = p.y + 6; } else if (buttonName.startsWith("Financial")) { // Financial np.x = buttonX + 7; np.y = p.y + 6; } else if (buttonName.startsWith("Energy")) { // Energy np.x = buttonX + 10; np.y = p.y + 6; } else if (buttonName.startsWith("Glycol")) { // Glycol np.x = buttonX + 10; np.y = p.y + 6; } else if (buttonName.startsWith("Main")) { // Main np.x = buttonX + 15; np.y = p.y + 6; } else { np.x = buttonX + 10; np.y = p.y + 6; // Rack just probably named wierd } _FTF_XPOS.setText(String.valueOf(np.x)); _FTF_YPOS.setText(String.valueOf(np.y)); }