Java Code Examples for java.awt.geom.Point2D

The following are top voted examples for showing how to use java.awt.geom.Point2D. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MFM   File: SwingUtils.java   Source Code and License 8 votes vote down vote up
public static void updateIcons(JTree tree) {
    Font defaultFont = UIManager.getFont("Tree.font");
    Font currentFont = tree.getFont();

    double newScale = (double)
            currentFont.getSize2D() / defaultFont.getSize2D();

    DefaultTreeCellRenderer renderer =
            (DefaultTreeCellRenderer) tree.getCellRenderer();
    renderer.setOpenIcon(
            scale(UIManager.getIcon("Tree.openIcon"), newScale, tree));
    renderer.setClosedIcon(
            scale(UIManager.getIcon("Tree.closedIcon"), newScale, tree));
    renderer.setLeafIcon(
            scale(UIManager.getIcon("Tree.leafIcon"), newScale, tree));

    Collection<Integer> iconSizes = Arrays.asList(
            renderer.getOpenIcon().getIconHeight(),
            renderer.getClosedIcon().getIconHeight(),
            renderer.getLeafIcon().getIconHeight());

    // Convert points to pixels
    Point2D p = new Point2D.Float(0, currentFont.getSize2D());
    FontRenderContext context =
            tree.getFontMetrics(currentFont).getFontRenderContext();
    context.getTransform().transform(p, p);
    int fontSizeInPixels = (int) Math.ceil(p.getY());

    tree.setRowHeight(
            Math.max(fontSizeInPixels, Collections.max(iconSizes) + 2));
}
 
Example 2
Project: geomapapp   File: TGrid.java   Source Code and License 6 votes vote down vote up
public static float temp( int yr, int day, Point2D point) {
	if(yr<79 || yr>98) return 999f; //Float.NaN;
	Point2D p = getMapXY(point);
	int x = (int)Math.floor(p.getX());
	if(x<0 || x>=46) return 998f; //Float.NaN;
	int y = (int)Math.floor(p.getY());
	if(y<0 || y>=40) return 997f; //Float.NaN;
	if(year!=yr) try {
		readGrids(yr);
	} catch (IOException ex) {
		return 996f; //Float.NaN;
	}
	if( t==null ) return 995f; //Float.NaN;
	double dx = p.getX()-x;
	double dy = p.getY()-y;
	double dxy = dx*dy;
	int d = day-1;
	float T = .01f * (float) ( (double)t[d][y][x]*(1d-dx-dy+dxy)
			+ (double)t[d][y][x+1]*(dx-dxy)
			+ (double)t[d][y+1][x]*(dy-dxy)
			+ (double)t[d][y+1][x+1]*(dxy) );
	return T;
}
 
Example 3
Project: cuttlefish   File: ARFLayout.java   Source Code and License 6 votes vote down vote up
private void advancePositions() {
	double c = 0;
	int nodeCount = graph.getNodeCount();

	for (int iter = 0; iter < updatesPerFrame; ++iter) {
		for (Node n : graph.getNodes()) {
			Point2D.Float f = getForceforNode(n);
			double log = Math.log10(nodeCount) == 0 ? 1 : Math
					.log10(nodeCount);
			double delta = graph.getDegree(n) > 1 ? (deltaT / log)
					/ Math.pow(graph.getDegree(n), 0.4) : (deltaT / log);

			f.setLocation(f.getX() * delta, f.getY() * delta);

			n.getNodeData().setX(
					n.getNodeData().x() + (float) (f.getX() / sensitivity));
			n.getNodeData().setY(
					n.getNodeData().y() + (float) (f.getY() / sensitivity));

			c += Math.abs(f.getX()) + Math.abs(f.getY());
		}
	}

	setChange(c);
	align(100, 100);
}
 
Example 4
Project: AI-RRT-Motion-Planning   File: Main.java   Source Code and License 6 votes vote down vote up
/**
 * convert a state from workspace to c space
 */
private static Config asvConfigToCfg(ASVConfig initialState, Test tester) {
    List<Point2D> positions = initialState.asvPositions;
    //length
    double [] pts = new double [initialState.getASVCount()+1];
    Point2D p0= positions.get(0);
    pts[0]=p0.getX();
    pts[1]=p0.getY();
    double prevAngle=0;
    for (int i=1;i<positions.size();i++){
        Point2D p1 = positions.get(i);
        double currentAngle = Math.atan2(p1.getY() - p0.getY(),
                p1.getX() - p0.getX());
        
        pts[i+1]=tester.normaliseAngle(PI+prevAngle-currentAngle);
        
        prevAngle=currentAngle;
        p0=p1;
    }
    Config cfg = new Config(pts);
    return cfg;
}
 
Example 5
Project: jfreechart-fx   File: ScrollHandlerFX.java   Source Code and License 6 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
Example 6
Project: cuttlefish   File: WeightedARF2Layout.java   Source Code and License 6 votes vote down vote up
public void advancePositions() {
	for (int i = 0; i < updatesPerFrame; i++) {
		for (Vertex v : graph.getVertices()) {
			if (!isFixed(v)) {
				Point2D c = transform( v);
				if (c != null) {
					Point2D f = getForceforNode(v);
					double deltaIndividual = 0;
					try {
						double log = Math.log10(getGraph().getVertexCount()) == 0 ? 1 : Math.log10(getGraph().getVertexCount()); 							
						deltaIndividual = getGraph().degree(v) > 1 ? (deltaT/log) / Math.pow(getGraph().degree(v), 0.4) : (deltaT/log);
					} catch (java.lang.IllegalArgumentException ex) {
						this.reset();
					}
					f.setLocation(f.getX() * deltaIndividual, f.getY() * deltaIndividual);
					c.setLocation(c.getX() + f.getX(), c.getY() + f.getY());
					new_change += Math.abs(f.getX()) + Math.abs(f.getY());
				}
			}
		}
	}
	change = new_change;
	new_change = 0;
	align(100, 100);
}
 
Example 7
Project: jaer   File: TrackDefineFilter.java   Source Code and License 6 votes vote down vote up
private void loadTrackFromFile(File file) throws HeadlessException, IOException, ClassNotFoundException {
    Object old = extractedTrack;
    if (file == null) {
        throw new IOException("null filename, can't load track from file - track needs to be saved first");
    }
    log.info("loading track data from " + file);
    extractedTrack =  SlotcarTrack.loadFromFile(file);
    // extractPoints = (LinkedList<Point2D.Float>) ois.readObject();  // unchecked cast exception
    extractPoints = new LinkedList<Point2D.Float>();
    for (Object o : extractedTrack.trackPoints) {
        extractPoints.add((Point2D.Float) o);
    }
    extractedTrack.getSupport().addPropertyChangeListener(this);
    extractedTrack.updateTrack(); // update other internal vars of track
    setTrackName(extractedTrack.getTrackName());
}
 
Example 8
Project: ramus   File: DFDFunction.java   Source Code and License 6 votes vote down vote up
protected int getTriangle(final FloatPoint point) {
    int res = -1;

    FloatPoint l = getLocation();

    for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
        GeneralPath gp = getTrianglePath(type);
        double y = point.getY() + l.getY();
        double x = point.getX() + l.getX();
        if (gp.contains(new Point2D.Double(x, y))) {
            res = type;
            break;
        }
    }

    return res;
}
 
Example 9
Project: 484_P7_1-Java   File: Ruling.java   Source Code and License 6 votes vote down vote up
public Point2D intersectionPoint(Ruling other) {
    Ruling this_l = this.expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT);
    Ruling other_l = other.expand(PERPENDICULAR_PIXEL_EXPAND_AMOUNT);
    Ruling horizontal, vertical;
    
    if (!this_l.intersectsLine(other_l)) {
        return null;
    }
    
    if (this_l.horizontal() && other_l.vertical()) {
        horizontal = this_l; vertical = other_l;
    }
    else if (this_l.vertical() && other_l.horizontal()) {
        vertical = this_l; horizontal = other_l;
    }
    else {
        throw new IllegalArgumentException("lines must be orthogonal, vertical and horizontal");
    }
    return new Point2D.Float(vertical.getLeft(), horizontal.getTop());        
}
 
Example 10
Project: AgentWorkbench   File: GraphEnvironmentMousePlugin.java   Source Code and License 6 votes vote down vote up
@Override
protected void pickContainedVertices(VisualizationViewer<GraphNode, GraphEdge> vv, Point2D down,Point2D out, boolean clear) {
	
	super.pickContainedVertices(vv, down, out, clear);
	NetworkModelAdapter netAdapter = this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter();
	
	// --- Get the selected nodes ----------------
	Set<GraphNode> nodesSelected = this.getVisViewer().getPickedVertexState().getPicked();
	// --- Get the related NetworkComponent's ---- 
	HashSet<NetworkComponent> components = netAdapter.getNetworkComponentsFullySelected(nodesSelected);
	if (components!=null) {
		// --- Run through NetworkComponents -----  
		for (NetworkComponent networkComponent : components) {
			Vector<GraphElement> elements = netAdapter.getGraphElementsFromNetworkComponent(networkComponent);
			for (GraphElement graphElement : elements) {
				if (graphElement instanceof GraphEdge) {
					this.getVisViewer().getPickedEdgeState().pick((GraphEdge) graphElement, true);
				}
			}
		}
	}
	
}
 
Example 11
Project: jdk8u-jdk   File: StandardGlyphVector.java   Source Code and License 6 votes vote down vote up
/**
 * !!! not used currently, but might be by getPixelbounds?
 */
public void pixellate(FontRenderContext renderFRC, Point2D loc, Point pxResult) {
    if (renderFRC == null) {
        renderFRC = frc;
    }

    // it is a total pain that you have to copy the transform.

    AffineTransform at = renderFRC.getTransform();
    at.transform(loc, loc);
    pxResult.x = (int)loc.getX(); // but must not behave oddly around zero
    pxResult.y = (int)loc.getY();
    loc.setLocation(pxResult.x, pxResult.y);
    try {
        at.inverseTransform(loc, loc);
    }
    catch (NoninvertibleTransformException e) {
        throw new IllegalArgumentException("must be able to invert frc transform");
    }
}
 
Example 12
Project: jdk8u-jdk   File: StandardGlyphVector.java   Source Code and License 5 votes vote down vote up
/**
 * Ensure that the positions array exists and holds position data.
 * If the array is null, this allocates it and sets default positions.
 */
private void initPositions() {
    if (positions == null) {
        setFRCTX();

        positions = new float[glyphs.length * 2 + 2];

        Point2D.Float trackPt = null;
        float track = getTracking(font);
        if (track != 0) {
            track *= font.getSize2D();
            trackPt = new Point2D.Float(track, 0); // advance delta
        }

        Point2D.Float pt = new Point2D.Float(0, 0);
        if (font.isTransformed()) {
            AffineTransform at = font.getTransform();
            at.transform(pt, pt);
            positions[0] = pt.x;
            positions[1] = pt.y;

            if (trackPt != null) {
                at.deltaTransform(trackPt, trackPt);
            }
        }
        for (int i = 0, n = 2; i < glyphs.length; ++i, n += 2) {
            getGlyphStrike(i).addDefaultGlyphAdvance(glyphs[i], pt);
            if (trackPt != null) {
                pt.x += trackPt.x;
                pt.y += trackPt.y;
            }
            positions[n] = pt.x;
            positions[n+1] = pt.y;
        }
    }
}
 
Example 13
Project: litiengine   File: PathFinder.java   Source Code and License 5 votes vote down vote up
public Path findDirectPath(final Point2D start, final Point2D target) {
  final Path2D path2D = new GeneralPath(Path2D.WIND_NON_ZERO);
  path2D.moveTo(start.getX(), start.getY());
  path2D.lineTo(target.getX(), target.getY());

  final List<Point2D> points = new ArrayList<>();
  points.add(start);
  points.add(target);
  return new Path(start, target, path2D, points);
}
 
Example 14
Project: rapidminer   File: AbstractChartPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Translates a Java2D point on the chart to a screen location.
 * 
 * @param java2DPoint
 *            the Java2D point.
 * 
 * @return The screen location.
 */

@Override
public Point translateJava2DToScreen(Point2D java2DPoint) {
	Insets insets = getInsets();
	int x = (int) (java2DPoint.getX() * this.scaleX + insets.left);
	int y = (int) (java2DPoint.getY() * this.scaleY + insets.top);
	return new Point(x, y);
}
 
Example 15
Project: alevin-svn2   File: MyGraphLayout.java   Source Code and License 5 votes vote down vote up
@Override
public void setLocation(V v, Point2D p) {
	// Update own storage.
	v.setCoordinateX(p.getX());
	v.setCoordinateY(p.getY());

	super.setLocation(v, p);
}
 
Example 16
Project: jaer   File: LabyrinthBallTracker.java   Source Code and License 5 votes vote down vote up
protected void createBall(Point2D.Float location) {
//        getEnclosedFilterChain().reset();
        // TODO somehow need to spawn an initial cluster at the starting location
        Cluster b = tracker.createCluster(new BasicEvent(lastTimestamp, (short) location.x, (short) location.y));
        b.setMass(10000); // some big number
        tracker.getClusters().add(b);
        ball = b;
    }
 
Example 17
Project: jaer   File: LabyrinthBallTracker.java   Source Code and License 5 votes vote down vote up
/**
 * Returns ball location from event tracker if it has a value, otherwise
 * from the convolution based tracker
 *
 * @return
 */
public Point2D.Float getBallLocation() {
    if ((ball != null) && ball.isVisible()) {
        return ball.getLocation();
    } else {
        return staticBallTracker.getBallLocation();
    }
}
 
Example 18
Project: geomapapp   File: FocalMechanismSolutionDB.java   Source Code and License 5 votes vote down vote up
public EarthquakeItem(Earthquake eq) {
	this.eq = eq;

	Point2D p = map.getProjection().getMapXY( eq.lon , eq.lat );
	x = p.getX();
	y = p.getY();
}
 
Example 19
Project: JavaPPTX   File: PPGroup.java   Source Code and License 5 votes vote down vote up
@Override
protected void dumpShape(PPOutputStream os) {
   os.print("<p:grpSp>");
   os.print("<p:nvGrpSpPr>");
   os.print("<p:cNvPr id='" + getShapeId() + "' " +
            "name='" + getName() + "'/>");
   os.print("<p:cNvGrpSpPr/>");
   os.print("<p:nvPr/>");
   os.print("</p:nvGrpSpPr>");
   os.print("<p:grpSpPr>");
   Point2D pt = getInitialLocation();
   Rectangle2D bb = getGroupBounds();
   String offsetTag = os.getOffsetTag(pt.getX() + bb.getX(),
                                      pt.getY() + bb.getY());
   os.print("<a:xfrm>");
   os.print("<a:off " + offsetTag + "/>");
   os.print("<a:ext cx='" + PPUtil.pointsToUnits(bb.getWidth()) + "' " +
            "cy='" + PPUtil.pointsToUnits(bb.getHeight()) + "'/>");
   os.print("<a:chOff " + offsetTag + "/>");
   os.print("<a:chExt cx='" + PPUtil.pointsToUnits(bb.getWidth()) + "' " +
            "cy='" + PPUtil.pointsToUnits(bb.getHeight()) + "'/>");
   os.print("</a:xfrm>");
   os.print("</p:grpSpPr>");
   Point2D start = getInitialLocation();
   os.adjustOffset(start.getX(), start.getY());
   for (PPShape shape : contents) {
      shape.dumpShape(os);
   }
   os.adjustOffset(-getX(), -getY());
   os.print("</p:grpSp>");
}
 
Example 20
Project: jaer   File: SlotcarTrack.java   Source Code and License 5 votes vote down vote up
/**
 * Changes the point with the given index to a new value
 */
public void setPoint(int idx, Point2D.Float newPoint) {
    if ((idx >= 0) && (idx < trackPoints.size())) {
        trackPoints.set(idx, newPoint);
        updateTrack();
    }
}
 
Example 21
Project: WordnetLoom   File: ViwnGraphViewUI.java   Source Code and License 5 votes vote down vote up
/**
 * scale visualisation to fill full visualization viewer space
 *
 * @author amusial
 */
protected void fillVV() {
    // scale
    // if layout was scaled, scale it to it original size
    if (vv.getRenderContext().getMultiLayerTransformer()
            .getTransformer(Layer.LAYOUT).getScaleX() > 1D) {
        (new LayoutScalingControl()).scale(vv, (1f / (float) vv
                        .getRenderContext().getMultiLayerTransformer()
                        .getTransformer(Layer.LAYOUT).getScaleX()),
                new Point2D.Double());
    }
    // get view bounds
    Dimension vd = vv.getPreferredSize();
    if (vv.isShowing()) {
        vd = vv.getSize();
    }
    // get visualisation layout size
    Dimension ld = vv.getGraphLayout().getSize();
    // finally scale it if view bounds are different than visualisation layer bounds
    if (vd.equals(ld) == false) {
        float heightRatio = (float) (vd.getWidth() / ld.getWidth());
        float widthRatio = (float) (vd
                .getHeight() / ld.getHeight());

        scaler.scale(vv, (heightRatio < widthRatio ? heightRatio
                : widthRatio), new Point2D.Double());
    }
}
 
Example 22
Project: WordnetLoom   File: ViwnLayout2.java   Source Code and License 5 votes vote down vote up
protected void correctGraph(Collection<ViwnNode> toCorrect, ViwnNode anode) {

        // boundary coordinates
        int minx, maxx, miny, maxy;

        // initialize boundary coordinates
        minx = maxx = (int) locations.get(anode).getX();
        miny = maxy = (int) locations.get(anode).getY();

        // for all nodes already place, check their locations
        for (ViwnNode vn : toCorrect) {
            Point2D p = locations.get(vn);
            if (p.getX() > maxx) {
                maxx = (int) p.getX();
            } else if (p.getX() < minx) {
                minx = (int) p.getX();
            }
            if (p.getY() > maxy) {
                maxy = (int) p.getY();
            } else if (p.getY() < miny) {
                miny = (int) p.getY();
            }
        }

        // replace nodes
        correctNode2PointMapping(toCorrect, -minx + distX, -miny + distY);

        // set visualisation size
        size = new Dimension((maxx - minx) + 2 * distX, (maxy - miny) + 2 * distY);

    }
 
Example 23
Project: OpenJSharp   File: TextLine.java   Source Code and License 5 votes vote down vote up
/**
 * Return the union of the visual bounds of all the components.
 * This incorporates the path.  It does not include logical
 * bounds (used by carets).
 */
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;

    for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
        TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
        Rectangle2D r = tlc.getVisualBounds();

        Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
        if (lp == null) {
            r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                      r.getWidth(), r.getHeight());
        } else {
            lp.pathToPoint(pt, false, pt);

            AffineTransform at = tlc.getBaselineTransform();
            if (at != null) {
                AffineTransform tx = AffineTransform.getTranslateInstance
                    (pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
                tx.concatenate(at);
                r = tx.createTransformedShape(r).getBounds2D();
            } else {
                r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                          r.getWidth(), r.getHeight());
            }
        }

        if (result == null) {
            result = r;
        } else {
            result.add(r);
        }
    }

    if (result == null) {
        result = new Rectangle2D.Float(Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
    }

    return result;
}
 
Example 24
Project: cuttlefish   File: ARF3Layout.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void advancePositions() {

	try{

        for (int i = 0; i < updatesPerFrame; i++) {
        	

        	
        	for (Object o : graph.getVertices()) {
                Vertex v = (Vertex) o;
                if(!isFixed(v)){
	                Point2D c = transform((V) v);
	                if(c != null){
		                Point2D f = getForceforNode(v);
		                double deltaIndividual = getGraph().degree((V)v) > 1 ? deltaT / Math.pow(getGraph().degree((V)v), 0.4) : deltaT;
		                f.setLocation(f.getX()*deltaIndividual, f.getY()*deltaIndividual);
		                c.setLocation(c.getX() + f.getX(), c.getY() + f.getY());
	                }
                }
            }
        }
	}catch(Exception e){
		System.err.println(e);
		e.printStackTrace();
	}
	align(100,100);
}
 
Example 25
Project: parabuild-ci   File: Outlier.java   Source Code and License 5 votes vote down vote up
/**
 * Compares this object with the specified object for order, based on
 * the outlier's point.
 *
 * @param   o the Object to be compared.
 * @return  a negative integer, zero, or a positive integer as this object
 *      is less than, equal to, or greater than the specified object.
 *
 */
public int compareTo(Object o) {
    Outlier outlier = (Outlier) o;
    Point2D p1 = getPoint();
    Point2D p2 = outlier.getPoint();
    if (p1.equals(p2)) {
        return 0;
    } 
    else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) {
        return -1;
    } 
    else {
        return 1;
    } 
}
 
Example 26
Project: ramus   File: ArrowPainter.java   Source Code and License 5 votes vote down vote up
private Point2D getPlusPoint(final int type, double rotateWidth) {
    if (type == MovingPanel.RIGHT)
        return new Point2D.Double(rotateWidth, 0);
    else if (type == MovingPanel.LEFT)
        return new Point2D.Double(-rotateWidth, 0);
    else if (type == MovingPanel.TOP)
        return new Point2D.Double(0, -rotateWidth);
    else if (type == MovingPanel.BOTTOM)
        return new Point2D.Double(0, rotateWidth);
    else
        return new Point2D.Double(0, 0);
}
 
Example 27
Project: incubator-netbeans   File: ScreenshotComponent.java   Source Code and License 5 votes vote down vote up
/** Computes the current image point, that is in the center in the current view area. */
private Point2D.Double computeCenterPoint() {
    Point p = scrollPane.getViewport().getViewPosition();
    Rectangle viewRect = scrollPane.getViewport().getViewRect();
    p.x += viewRect.width/2;
    p.y += viewRect.height/2;
    return new Point2D.Double(p.x / scale, p.y / scale);
}
 
Example 28
Project: geomapapp   File: GeneralUtils.java   Source Code and License 5 votes vote down vote up
/**
    * Find the cumulative distance between an array of points
    * @param pts
    * @return
    */
public static double cumulativeDistance(Point2D[] pts) {
	if( pts==null ) return 0.;
	try{
		double d = 0.;
		for (int i=1; i<pts.length; i++) {
			Point2D[] points = {pts[i-1], pts[i]};
			d += distance(points);
		}
		return d;
	} catch (Exception e) {
		return 0;
	}
}
 
Example 29
Project: openjdk-jdk10   File: RadialGradientPrintingTest.java   Source Code and License 5 votes vote down vote up
public void doPaint(Graphics2D g2d) {

        g2d.translate(DIM*0.2, DIM*0.2);
        Shape s = new Rectangle2D.Float(0, 0, DIM*2, DIM*2);

        // RadialGradientPaint
        Point2D centre = new Point2D.Float(DIM/2.0f, DIM/2.0f);
        float radius = DIM/2.0f;
        Point2D focus = new Point2D.Float(DIM/3.0f, DIM/3.0f);
        float stops[] = {0.0f, 1.0f};
        Color colors[] =  { Color.red, Color.white} ;

        RadialGradientPaint rgp =
           new RadialGradientPaint(centre, radius, focus, stops, colors,
              RadialGradientPaint.CycleMethod.NO_CYCLE);
        g2d.setPaint(rgp);
        g2d.fill(s);

        g2d.translate(DIM*2.2, 0);
        Color colors1[] =  { Color.red, Color.blue, Color.green} ;
        float stops1[] = {0.0f, 0.5f, 1.0f};
        RadialGradientPaint rgp1 =
           new RadialGradientPaint(centre, radius, focus, stops1, colors1,
              RadialGradientPaint.CycleMethod.REFLECT);
        g2d.setPaint(rgp1);
        g2d.fill(s);

        g2d.translate(-DIM*2.2, DIM*2.2);
        Color colors2[] =  { Color.red, Color.blue, Color.green, Color.white} ;
        float stops2[] = {0.0f, 0.3f, 0.6f, 1.0f};
        RadialGradientPaint rgp2 =
           new RadialGradientPaint(centre, radius, focus, stops2, colors2,
              RadialGradientPaint.CycleMethod.REPEAT);
        g2d.setPaint(rgp2);
        g2d.fill(s);

    }
 
Example 30
Project: jaer   File: ApsNoiseStatistics.java   Source Code and License 5 votes vote down vote up
private void setTemporalNoiseLinePointsFromMousePoints(Point2D.Float start, Point2D.Float end) {
    final float offset = .1f;
    final float x0 = chip.getSizeX() * offset, y0 = chip.getSizeY() * offset, x1 = chip.getSizeX() * (1 - offset), y1 = chip.getSizeY() * (1 - offset);
    msp = start;
    mep = end;
    dsp.x = (float) meanrange * (msp.x - x0) / (x1 - x0);
    dep.x = (float) meanrange * (mep.x - x0) / (x1 - x0);
    dsp.y = (float) varrange * (msp.y - y0) / (y1 - y0);
    dep.y = (float) varrange * (mep.y - y0) / (y1 - y0);
}
 
Example 31
Project: parabuild-ci   File: CombinedDomainCategoryPlot.java   Source Code and License 5 votes vote down vote up
/**
 * Multiplies the range on the range axis/axes by the specified factor.
 *
 * @param factor  the zoom factor.
 * @param info  the plot rendering info.
 * @param source  the source point.
 */
public void zoomRangeAxes(double factor, PlotRenderingInfo info, 
                          Point2D source) {
    CategoryPlot subplot = findSubplot(info, source);
    if (subplot != null) {
        subplot.zoomRangeAxes(factor, info, source);
    }
}
 
Example 32
Project: AI-RRT-Motion-Planning   File: Test.java   Source Code and License 5 votes vote down vote up
/**
 * Returns whether the given configuration has sufficient area.
 *
 * @param cfg
 *            the configuration to test.
 * @return whether the given configuration has sufficient area.
 */
public boolean hasEnoughArea(ASVConfig cfg) {
    double total = 0;
    List<Point2D> points = cfg.getASVPositions();
    points.add(points.get(0));
    points.add(points.get(1));
    for (int i = 1; i < points.size() - 1; i++) {
        total += points.get(i).getX()
                * (points.get(i + 1).getY() - points.get(i - 1).getY());
    }
    double area = Math.abs(total) / 2;
    return (area >= getMinimumArea(cfg.getASVCount()) - maxError);
}
 
Example 33
Project: litiengine   File: Emitter.java   Source Code and License 5 votes vote down vote up
private void renderParticles(final Graphics2D g, final ParticleRenderType renderType) {
  final Point2D origin = this.getLocation();
  this.particles.forEach(particle -> {
    if (particle.getParticleRenderType() == renderType) {
      particle.render(g, origin);
    }
  });
}
 
Example 34
Project: OpenJSharp   File: SunLayoutEngine.java   Source Code and License 5 votes vote down vote up
public void layout(FontStrikeDesc desc, float[] mat, int gmask,
                   int baseIndex, TextRecord tr, int typo_flags,
                   Point2D.Float pt, GVData data) {
    Font2D font = key.font();
    FontStrike strike = font.getStrike(desc);
    long layoutTables = 0;
    if (font instanceof TrueTypeFont) {
        layoutTables = ((TrueTypeFont) font).getLayoutTableCache();
    }
    nativeLayout(font, strike, mat, gmask, baseIndex,
         tr.text, tr.start, tr.limit, tr.min, tr.max,
         key.script(), key.lang(), typo_flags, pt, data,
         font.getUnitsPerEm(), layoutTables);
}
 
Example 35
Project: jaer   File: RollingLinearRegression.java   Source Code and License 5 votes vote down vote up
/** Sets the window length.  Clears the accumulated data.
 @param length the number of points to fit 
 @see #LENGTH_DEFAULT
 */
synchronized public void setLength(int length) {
    this.length = length;
    points=new LinkedList<Point2D.Float>();
    sx=0;
    sy=0;
    sxx=0;
    sxy=0;
}
 
Example 36
Project: incubator-netbeans   File: Term.java   Source Code and License 5 votes vote down vote up
private void massage_glyphs(GlyphVector gv, int start, int n, Line l) {
    Point2D pos0 = gv.getGlyphPosition(0);

    // There's one big assumption here that in a monospaced font all the
    // Y placements are identical. So we use the placement for the first
    // glyph only.
    newp.y = (int) pos0.getY();

    int col = (int) pos0.getX();
    for (int gx = 0; gx < n; gx++) {
        newp.x = col;
        gv.setGlyphPosition(gx, newp);
        col += l.width(metrics, start + gx) * metrics.width;
    }
}
 
Example 37
Project: MicroSim   File: Micro_Sim.java   Source Code and License 5 votes vote down vote up
public void start() {
    frameRate(1000);

    for(int i = 0; i < 5; i++) {
        AddGameObject(new Organism(this, new Point2D.Float(ThreadLocalRandom.current().nextInt(200, 800), ThreadLocalRandom.current().nextInt(200, 800))));
    }
    NextRound();
}
 
Example 38
Project: DicomViewer   File: DragAnim.java   Source Code and License 5 votes vote down vote up
private void updateVelocity(final Point2D p0, final Point2D p1, final long t0, final long t1) {
    final double dt = t1 - t0;
    if ((dt < DT_MAX) && (dt > 0)){
        dragVelocity.set(p1, p0);
        dragVelocity.scale(1./dt); // Vitesse en pixel par milliseconde
        if (dragVelocity.getLength() > MAX_VELOCITY) { // Limitation de vitesse !
            dragVelocity.setLength(MAX_VELOCITY);    
        }
    } else {
        dragVelocity.set(0,0); // Vitesse nulle
    }
    lastEventTime = t1;
}
 
Example 39
Project: geomapapp   File: XMap.java   Source Code and License 5 votes vote down vote up
/**
 	Sets the coordinates of mouse to be displayed.
 	@param p mouse location.
 */
public void setXY( Point p ) {
	if( p==null ) {
		if( app instanceof MapApp ) {
			((MapApp)app).tools.info.setText("");
		} else if(app instanceof PolarMapApp ) {
			((PolarMapApp)app).tools.info.setText("");
		}
		return;
	}
	Point2D.Double pt = (Point2D.Double)proj.getRefXY( getScaledPoint(p));
	setLonLat( pt );
}
 
Example 40
Project: jaer   File: Steadicam.java   Source Code and License 5 votes vote down vote up
@Override
synchronized public void setFilterEnabled(boolean yes) {
    super.setFilterEnabled(yes);
    setCameraRotationEstimator(cameraRotationEstimator); // reflag enabled/disabled state of motion computation
    getEnclosedFilterChain().reset();
    if (!yes) {
        setPanTiltEnabled(false); // turn off servos, close interface
        if (chip.getAeViewer() != null && chip.getCanvas() != null && chip.getCanvas().getDisplayMethod() instanceof ChipRendererDisplayMethodRGBA) {
            ChipRendererDisplayMethodRGBA displayMethod = (ChipRendererDisplayMethodRGBA) chip.getCanvas().getDisplayMethod(); // TODO not ideal (tobi)
            displayMethod.setImageTransform(new Point2D.Float(0, 0), 0);
        }
    } else {
        resetFilter(); // reset on enabled to prevent large timestep anomalies
    }
}
 
Example 41
Project: freecol   File: MapViewer.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the ImageLibrary and calculates various items that depend
 * on tile size.
 *
 * @param lib an {@code ImageLibrary} value
 */
private void setImageLibraryAndUpdateData(ImageLibrary lib) {
    this.lib = lib;
    tv.setImageLibraryAndUpdateData(lib);
    // ATTENTION: we assume that all base tiles have the same size
    Dimension tileSize = lib.tileSize;
    tileHeight = tileSize.height;
    tileWidth = tileSize.width;
    halfHeight = tileHeight/2;
    halfWidth = tileWidth/2;

    int dx = tileWidth/16;
    int dy = tileHeight/16;
    int ddx = dx + dx/2;
    int ddy = dy + dy/2;

    // small corners
    controlPoints.put(Direction.N, new Point2D.Float(halfWidth, dy));
    controlPoints.put(Direction.E, new Point2D.Float(tileWidth - dx, halfHeight));
    controlPoints.put(Direction.S, new Point2D.Float(halfWidth, tileHeight - dy));
    controlPoints.put(Direction.W, new Point2D.Float(dx, halfHeight));
    // big corners
    controlPoints.put(Direction.SE, new Point2D.Float(halfWidth, tileHeight));
    controlPoints.put(Direction.NE, new Point2D.Float(tileWidth, halfHeight));
    controlPoints.put(Direction.SW, new Point2D.Float(0, halfHeight));
    controlPoints.put(Direction.NW, new Point2D.Float(halfWidth, 0));
    // small corners
    borderPoints.put(Direction.NW, new Point2D.Float(dx + ddx, halfHeight - ddy));
    borderPoints.put(Direction.N,  new Point2D.Float(halfWidth - ddx, dy + ddy));
    borderPoints.put(Direction.NE, new Point2D.Float(halfWidth + ddx, dy + ddy));
    borderPoints.put(Direction.E,  new Point2D.Float(tileWidth - dx - ddx, halfHeight - ddy));
    borderPoints.put(Direction.SE, new Point2D.Float(tileWidth - dx - ddx, halfHeight + ddy));
    borderPoints.put(Direction.S,  new Point2D.Float(halfWidth + ddx, tileHeight - dy - ddy));
    borderPoints.put(Direction.SW, new Point2D.Float(halfWidth - ddx, tileHeight - dy - ddy));
    borderPoints.put(Direction.W,  new Point2D.Float(dx + ddx, halfHeight + ddy));

    borderStroke = new BasicStroke(dy);
    gridStroke = new BasicStroke(lib.getScaleFactor());
}
 
Example 42
Project: litiengine   File: PhysicsEngine.java   Source Code and License 5 votes vote down vote up
private boolean resolveCollisionForNewPosition(IMovableEntity entity, Point2D newPosition) {
  // resolve collision for new location
  if (this.collidesWithAnything(entity, entity.getCollisionBox(newPosition)) != null) {
    final Point2D resolvedPosition = this.resolveCollision(entity, newPosition);
    entity.setLocation(resolvedPosition);
    return true;
  }

  return false;
}
 
Example 43
Project: cuttlefish   File: ARFLayout.java   Source Code and License 5 votes vote down vote up
private Point2D.Float getForceforNode(Node node) {
    double numNodes = graph.getNodeCount();

    Point2D.Float mDot = new Point2D.Float();

    if (node.getNodeData().x() == 0 && node.getNodeData().y() == 0) {
        return mDot;
    }

    for(Node otherNode : graph.getNodes() ) {
        if(node == otherNode) continue;
        
        if (otherNode.getNodeData().x() == 0 && otherNode.getNodeData().y() == 0 ) {
            continue;
        }
                    
        float tempX = otherNode.getNodeData().x()  - node.getNodeData().x();
        float tempY = otherNode.getNodeData().y()  - node.getNodeData().y();
        
        float multiplier = graph.isAdjacent(node, otherNode) ? a : 1;
        multiplier *= attraction / Math.sqrt(numNodes);

        mDot.setLocation(mDot.getX() + tempX * multiplier, mDot.getY() + tempY * multiplier);
        
        multiplier = 1 / (float)Math.sqrt(tempX*tempX +  tempY*tempY);
        mDot.setLocation(mDot.getX() - tempX * multiplier * b, mDot.getY() - tempY * multiplier * b);
    }
    
    if (mDot.distance(0, 0) > forceCutoff) {
        float mult = forceCutoff / (float)mDot.distance(0, 0);
        mDot.setLocation(mDot.getX() * mult, mDot.getY() * mult);
    }

    return mDot;
}
 
Example 44
Project: geomapapp   File: GridToWorldWindTiler.java   Source Code and License 5 votes vote down vote up
private void gridToTile(int tileX, int tileY, int level, File parent) throws IOException{
		double delta = levelZeroDelta / Math.pow(2, level);

//		double lon1 = lon0 + delta;
		double lat0 = getLatFromTileY(tileY, level, levelZeroDelta);
		double lat1 = lat0 + delta;

		int multiplier = getLonMultiplier(lat0, lat1);
		double lon0 = getLonFromTile(lat0, lat1, tileX, level, levelZeroDelta);
		double lon1 = lon0 + delta * multiplier;

		double[] tileWESN = new double[] {lon0, lon1, lat0, lat1};

		MapProjection proj = grid.getProjection();
		Point2D ul = proj.getMapXY(lon0, lat1);
		Point2D lr = proj.getMapXY(lon1, lat0);

		Rectangle bounds = new Rectangle();
		bounds.x = (int)Math.floor(ul.getX());
		bounds.y = (int)Math.floor(ul.getY());
		bounds.width = (int) Math.ceil(lr.getX()) - bounds.x;
		bounds.height = (int) Math.ceil(lr.getY()) - bounds.y;

		Grid2D subGrid = GridUtilities.getSubGrid(bounds, grid);
		BufferedImage tileImage = renderer.gridImage(subGrid).image;

//		System.out.println(bounds + "\t" + grid.getBounds());

		tileImage = imageProcessor.processImage(tileImage, tileWESN, tileWESN);

		BufferedImage scaledTileImage = new BufferedImage(TILE_SIZE, TILE_SIZE, tileImage.getType());
		Graphics2D g = scaledTileImage.createGraphics();
		g.setComposite(AlphaComposite.Src);
		g.drawImage(tileImage, 0, 0, TILE_SIZE, TILE_SIZE, null);

		StringBuffer sb = new StringBuffer();
		sb.append(tileY).append("_").append(tileX).append(".").append(outputFormat);

		ImageIO.write(scaledTileImage, outputFormat, new File(parent, sb.toString()));
	}
 
Example 45
Project: JavaGraph   File: LayoutIO.java   Source Code and License 5 votes vote down vote up
/**
 * Converts pairs of elements of a string array to a list of points.
 * @param s array containing string representations of coordinates
 * @param i index from which the string array will be converted to points
 */
public static List<Point2D> toPoints(String[] s, int i) {
    List<Point2D> result = new LinkedList<>();
    for (int j = i; j < s.length - 1; j += 2) {
        result.add(toPoint(s, j));
    }
    return result;
}
 
Example 46
Project: geomapapp   File: PolarProjection.java   Source Code and License 5 votes vote down vote up
/**
	Gets the reference point from the map coordinates.
	@param mapX the map coordinates x value.
	@param mapY the map coordinates y value.
	@return the reference point.
*/
public Point2D getRefXY(double mapX, double mapY) {
	double x = mapX - poleX;
	double y = mapY - poleY;
	double r = Math.sqrt(x*x + y*y);
	double latitude = getLatitude( r );
	double longitude = refLon;
	if(hemisphere==NORTH) longitude -= Math.toDegrees(Math.atan2(y, x));
	else longitude += Math.toDegrees(Math.atan2(y, x));
	return new Point2D.Double( longitude, latitude);
}
 
Example 47
Project: parabuild-ci   File: CategoryPlot.java   Source Code and License 5 votes vote down vote up
/**
 * Zooms in on the range axes.
 * 
 * @param lowerPercent  the lower bound.
 * @param upperPercent  the upper bound.
 * @param state  the plot state.
 * @param source  the source point (in Java2D space) for the zoom.
 */
public void zoomRangeAxes(double lowerPercent, double upperPercent, 
                          PlotRenderingInfo state, Point2D source) {
    for (int i = 0; i < this.rangeAxes.size(); i++) {
        ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i);
        if (rangeAxis != null) {
            rangeAxis.zoomRange(lowerPercent, upperPercent);
        }
    }
}
 
Example 48
Project: geomapapp   File: RenderingTools.java   Source Code and License 4 votes vote down vote up
private void calculateGridStatistics() {
	double landArea = 0;
	double oceanArea = 0;
	Grid2D g2d = grid.getGrid();
	Grid2D.Boolean mask = grid.getLandMask();

	if (g2d == null || grid.getLandMask() == null) return;

	Rectangle bounds = g2d.getBounds();
	MapProjection proj = g2d.getProjection();

	float landZ, oceanZ;
	int landN, oceanN;
	landZ = oceanZ = 0;
	landN = oceanN = 0;

	for (int y = 0; y < mask.getBounds().height; y++) {
		int yy = y + bounds.y;
		Point2D refXY1 = proj.getRefXY(bounds.x, yy - .5);
		Point2D refXY2 = proj.getRefXY(bounds.x, yy + .5);

		XYZ r1 = XYZ.LonLat_to_XYZ(refXY1);
		XYZ r2 = XYZ.LonLat_to_XYZ(refXY2);
		double angle = Math.acos( r1.dot(r2) );
		double dist1 = Projection.major[0] * angle/1000.;

		refXY1 = proj.getRefXY(bounds.x, yy);
		refXY2 = proj.getRefXY(bounds.x + 1, yy);
		r1 = XYZ.LonLat_to_XYZ(refXY1);
		r2 = XYZ.LonLat_to_XYZ(refXY2);
		angle = Math.acos( r1.dot(r2) );
		double dist2 = Projection.major[0] * angle/1000.;

		double area = dist1 * dist2;

		for (int x = 0; x < bounds.width; x++) {
			int xx = x + bounds.x;
			double z = g2d.valueAt(xx, yy);
			if (!Double.isNaN(z)) {
				if (mask.booleanValue(xx, yy)) {
					landZ += z;
					landN++;
					landArea += area;
				}
				else {
					oceanZ += z;
					oceanN++;
					oceanArea += area;
				}
			}
		}
	}

	this.landArea  = landArea;
	this.oceanArea = oceanArea;
	this.landMeanZ  = landZ / landN;
	this.oceanMeanZ = oceanZ / oceanN;
	this.totalMeanZ = (landZ + oceanZ) / (landN + oceanN);

	updateGridStatistics();
}
 
Example 49
Project: QN-ACTR-Release   File: SelectState.java   Source Code and License 4 votes vote down vote up
/**
 * Handles press event, it selects the cell that is under the pointer
 * if there is no cell deselects. There is also the possibility of
 * activating the marquee handler
 *
 * @param e press mouse event
 */
@Override
public void handlePress(MouseEvent e) {
	ml.setHandler(null);

	if (!e.isConsumed() && mediator.isGraphEnabled()) {
		mediator.graphRequestFocus();
		int s = mediator.getTolerance();
		Rectangle2D r = mediator.fromScreen(new Rectangle(e.getX() - s, e.getY() - s, 2 * s, 2 * s));
		Point2D point = mediator.fromScreen(new Point(e.getPoint()));
		if (!(ml.getFocus() != null && ml.getFocus().intersects(mediator.getGraph(), r))) {
			ml.setFocus(null);
		}
		// Avoid toggling of selection between inner components and blocking region
		CellView next = mediator.getNextViewAt(ml.getFocus(), point.getX(), point.getY());
		if (next != null && next.getCell() != null) {
			if (!(ml.getFocus() != null && next.getCell() instanceof BlockingRegion)) {
				ml.setCell(next);
			}
		}
		if (ml.getFocus() == null) {
			ml.setFocus(ml.getCell());
		}

		if (!mediator.isForceMarqueeEvent(e)) {
			if (e.getClickCount() == mediator.getEditClickCount() && ml.getFocus() != null
			//&& ml.getFocus().isLeaf()
			//&& ml.getFocus().getParentView() == null
			) {
				// Start Editing Only if cell is editable - BERTOLI MARCO
				if (mediator.isCellEditable(ml.getFocus().getCell())) {
					ml.handleEditTrigger(ml.getFocus().getCell());
					e.consume();
					ml.setCell(null);
				} // Otherwise do nothing - BERTOLI MARCO
				else {
					e.consume();
				}
			} else if (!mediator.isToggleSelectionEvent(e)) {
				if (ml.getHandle() != null) {
					ml.setHandler(ml.getHandle());
					ml.getHandle().mousePressed(e);
				}
				// Immediate Selection
				if (!e.isConsumed() && ml.getCell() != null && !mediator.isCellSelected(ml.getCell())) {
					mediator.selectCellForEvent(ml.getCell().getCell(), e);
					ml.setFocus(ml.getCell());
					if (ml.getHandle() != null) {
						ml.getHandle().mousePressed(e);
						ml.setHandler(ml.getHandle());
					}
					e.consume();
					ml.setCell(null);
				}
			}
		}

		//Marquee Selection
		if (!e.isConsumed() && (!mediator.isToggleSelectionEvent(e) || ml.getFocus() == null)) {
			if (ml.getMarquee() != null) {
				ml.getMarquee().mousePressed(e);
				ml.setHandler(ml.getMarquee());
			}
		}
	}

}
 
Example 50
Project: geomapapp   File: XMap.java   Source Code and License 4 votes vote down vote up
public void setLonLat( double lon, double lat) {
	setLonLat( new Point2D.Double(lon, lat) );
}
 
Example 51
Project: 484_P7_1-Java   File: Ruling.java   Source Code and License 4 votes vote down vote up
public Ruling(float top, float left, float width, float height) {
    this(new Point2D.Float(left, top), new Point2D.Float(left+width, top+height));
}
 
Example 52
Project: JavaGraph   File: LayoutIO.java   Source Code and License 4 votes vote down vote up
/** Checks if the source and target point lie within the source and target nodes,
 * and corrects the points if this is not the case.
 * Fix for SF Bug #3562111.
 */
public static void correctPoints(List<Point2D> points, JVertexLayout sourceLayout,
    JVertexLayout targetLayout) {
    correctPoint(points, 0, sourceLayout);
    correctPoint(points, points.size() - 1, targetLayout);
}
 
Example 53
Project: ramus   File: GEFComponent.java   Source Code and License 4 votes vote down vote up
private Point2D getBottomSelectionPoint() {
    Rectangle2D rect = selection.getTranslateRectangle();
    return translate(new Point2D.Double(rect.getCenterX(), rect.getMaxY()));
}
 
Example 54
Project: qupath-tracking-extension   File: TrackerFeatureOverlay.java   Source Code and License 4 votes vote down vote up
private void drawPointsTrail(Graphics2D g2d, double downsampleFactor, Rectangle clippingRectangle, Fixations fixations) {
    g2d.setStroke(new BasicStroke((downsampleFactor > 1) ? (float) downsampleFactor : 1));

    double[] zoomLevel;
    Point2D[] points = fixations.getCentroids();
    zoomLevel = new double[fixations.getFixations().size()];
    for (int j = 0; j < fixations.getFixations().size(); j++) {
        zoomLevel[j] = fixations.getFixations().get(j).calculateAverageZoom(
                viewer.getServer().getAveragedPixelSizeMicrons());
    }

    Point2D previousPoint = null;
    for (int i = 0; i < points.length; i++) {
        Point2D point = points[i];

        if (point != null) {
            if (clippingRectangle.contains(point)) {

                Color lowColor = fixations.getLowColor();
                Color medColor = fixations.getMedColor();
                Color highColor = fixations.getHighColor();

                g2d.setColor(lowColor);
                if (zoomLevel[i] < lowZoomThreshold.get()) {
                    g2d.setColor(medColor);
                }
                if (zoomLevel[i] < medZoomThreshold.get()) {
                    g2d.setColor(highColor);
                }
                g2d.setStroke(new BasicStroke((float) (downsampleFactor * fixations.getThicknessScalar())));

                if (previousPoint != null) {
                    g2d.drawLine(
                            (int) point.getX(), (int) point.getY(),
                            (int) previousPoint.getX(), (int) previousPoint.getY());
                }

                if (fixations.getFixations() != null) {
                    g2d.setStroke(new BasicStroke((float) downsampleFactor));
                    double circleSizeCoef = (downsampleFactor * fixations.getDurations()[i] / 30) *
                            fixations.getDurationSizeScalarScalar();

                    g2d.fillOval(
                            (int) point.getX() - (int) (circleSizeCoef / 2),
                            (int) point.getY() - (int) (circleSizeCoef / 2),
                            (int) circleSizeCoef,
                            (int) circleSizeCoef);

                    if (doPaintNumbers) {
                        Font font = new Font("Impact", Font.BOLD, (int) (30 * downsampleFactor));
                        g2d.setFont(font);
                        String str = Integer.toString(i + 1);
                        g2d.setColor(Color.WHITE);
                        g2d.drawString(str, (int) point.getX(), (int) point.getY());

                        GlyphVector gv = font.createGlyphVector(g2d.getFontRenderContext(), str);
                        Shape s = gv.getOutline((int) point.getX(), (int) point.getY());
                        g2d.setColor(Color.BLACK);
                        g2d.draw(s);
                    }
                }
            }
            previousPoint = point;
        }
    }
}
 
Example 55
Project: parabuild-ci   File: LongNeedle.java   Source Code and License 4 votes vote down vote up
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 
                          Point2D rotate, double angle) {

    GeneralPath shape1 = new GeneralPath();
    GeneralPath shape2 = new GeneralPath();
    GeneralPath shape3 = new GeneralPath();

    float minX = (float) plotArea.getMinX();
    float minY = (float) plotArea.getMinY();
    float maxX = (float) plotArea.getMaxX();
    float maxY = (float) plotArea.getMaxY();
    //float midX = (float) (minX + (plotArea.getWidth() * getRotateX()));
    //float midY = (float) (minY + (plotArea.getHeight() * getRotateY()));
    float midX = (float) (minX + (plotArea.getWidth() * 0.5));
    float midY = (float) (minY + (plotArea.getHeight() * 0.8));
    float y = maxY - (2 * (maxY - midY));
    if (y < minY) {
        y = minY;
    }
    shape1.moveTo(minX, midY);
    shape1.lineTo(midX, minY);
    shape1.lineTo(midX, y);
    shape1.closePath();

    shape2.moveTo(maxX, midY);
    shape2.lineTo(midX, minY);
    shape2.lineTo(midX, y);
    shape2.closePath();

    shape3.moveTo(minX, midY);
    shape3.lineTo(midX, maxY);
    shape3.lineTo(maxX, midY);
    shape3.lineTo(midX, y);
    shape3.closePath();

    Shape s1 = shape1;
    Shape s2 = shape2;
    Shape s3 = shape3;

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation huston, please spin me
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        s1 = shape1.createTransformedShape(transform);
        s2 = shape2.createTransformedShape(transform);
        s3 = shape3.createTransformedShape(transform);
    }


    if (getHighlightPaint() != null) {
        g2.setPaint(getHighlightPaint());
        g2.fill(s3);
    }

    if (getFillPaint() != null) {
        g2.setPaint(getFillPaint());
        g2.fill(s1);
        g2.fill(s2);
    }


    if (getOutlinePaint() != null) {
        g2.setStroke(getOutlineStroke());
        g2.setPaint(getOutlinePaint());
        g2.draw(s1);
        g2.draw(s2);
        g2.draw(s3);
    }
}
 
Example 56
Project: jaer   File: LowpassFilter2D.java   Source Code and License 4 votes vote down vote up
public Point2D.Float getValue2D(){
    point.x=x.getValue();
    point.y=y.getValue();
    return point;
}
 
Example 57
Project: jaer   File: SlotcarTrack.java   Source Code and License 4 votes vote down vote up
/**
 * Adds a Point2D2D to the end of the track
 */
public void addPoint(Point2D.Float newPoint) {
    trackPoints.addLast(newPoint);
    //        updateTrack(); // don't update for every point or else it takes forvever when extracting track
}
 
Example 58
Project: openjdk-jdk10   File: AttributeValues.java   Source Code and License 4 votes vote down vote up
public static AffineTransform extractXRotation(AffineTransform tx,
                                               boolean andTranslation) {
    return extractRotation(new Point2D.Double(1, 0), tx, andTranslation);
}
 
Example 59
Project: OpenJSharp   File: NativeFont.java   Source Code and License 4 votes vote down vote up
void getGlyphMetrics(long pScalerContext, int glyphCode,
                     Point2D.Float metrics) {
}
 
Example 60
Project: geomapapp   File: PDBLocation.java   Source Code and License 4 votes vote down vote up
public void project( Projection proj ) {
	Point2D p = proj.getMapXY( new Point2D.Float(lon, lat) );
	x = (float)p.getX();
	y = (float)p.getY();
}