Java Code Examples for java.awt.geom.Point2D

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/builder/.

Source file: LyndOBrienView.java

  23 
vote

private Point2D.Double convertToChartCoordinates(Point point){
  ChartRenderingInfo info=getChartRenderingInfo();
  Rectangle2D dataArea=info.getPlotInfo().getDataArea();
  Point2D p=translateScreenToJava2D(new Point(point.x,point.y));
  XYPlot plot=getChart().getXYPlot();
  RectangleEdge domainAxisEdge=plot.getDomainAxisEdge();
  RectangleEdge rangeAxisEdge=plot.getRangeAxisEdge();
  ValueAxis domainAxis=plot.getDomainAxis();
  ValueAxis rangeAxis=plot.getRangeAxis();
  return new Point2D.Double(domainAxis.java2DToValue(p.getX(),dataArea,domainAxisEdge),rangeAxis.java2DToValue(p.getY(),dataArea,rangeAxisEdge));
}
 

Example 2

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: Utility.java

  22 
vote

private static AffineTransform findTranslation(AffineTransform at,BufferedImage bi){
  Point2D p2din, p2dout;
  p2din=new Point2D.Double(0.0,0.0);
  p2dout=at.transform(p2din,null);
  double ytrans=p2dout.getY();
  p2din=new Point2D.Double(0,bi.getHeight());
  p2dout=at.transform(p2din,null);
  double xtrans=p2dout.getX();
  AffineTransform tat=new AffineTransform();
  tat.translate(-xtrans,-ytrans);
  return tat;
}
 

Example 3

From project alg-vis, under directory /src/algvis/core/.

Source file: Node.java

  22 
vote

/** 
 * position the node above top of the screen and set its state to ALIVE, so the node is ready to come to screen now
 */
protected void getReady(){
  if (D.M.screen.V.at != null) {
    Point2D p=D.M.screen.V.r2v(0,0);
    toy=y=(int)p.getY() - 5 * Node.radius;
  }
 else {
    tox=x=0;
    toy=y=-5 * Node.radius;
  }
}
 

Example 4

From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/visualizers/iframe/tree/.

Source file: ConstituentLayouter.java

  22 
vote

private CubicCurve2D secedgeCurve(VerticalOrientation verticalOrientation,Rectangle2D sourceRect,Rectangle2D targetRect){
  Pair<RectangleSide> sidePair=findBestConnection(sourceRect,targetRect);
  Point2D startPoint=sideMidPoint(sourceRect,sidePair.getFirst());
  Point2D endPoint=sideMidPoint(targetRect,sidePair.getSecond());
  double middleX=(startPoint.getX() + endPoint.getX()) / 2.0;
  double middleY=50 * -verticalOrientation.value + (startPoint.getY() + endPoint.getY()) / 2;
  return new CubicCurve2D.Double(startPoint.getX(),startPoint.getY(),middleX,middleY,middleX,middleY,endPoint.getX(),endPoint.getY());
}
 

Example 5

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/figure/.

Source file: AbstractPointFigure.java

  22 
vote

@Override public void rotate(Point2D point,double theta){
  final AffineTransform transform=new AffineTransform();
  transform.rotate(theta,point.getX(),point.getY());
  Point2D point2D=transform.transform(getLocation(),null);
  setLocation(point2D);
}
 

Example 6

From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/.

Source file: ModelGraphPanel.java

  22 
vote

/** 
 * Zoom in or out to magnify by the specified factor, from the current magnification.
 * @param factor The magnification factor (relative to 1.0).
 */
public void zoom(double factor){
  JCanvas canvas=_jgraph.getGraphPane().getCanvas();
  AffineTransform current=canvas.getCanvasPane().getTransformContext().getTransform();
  Point2D center=getCenter();
  current.scale(factor,factor);
  canvas.getCanvasPane().setTransform(current);
  setCenter(center);
  if (_graphPanner != null) {
    _graphPanner.repaint();
  }
}
 

Example 7

From project droidex_1, under directory /src/com/commonsware/droidex/image/.

Source file: RotateImageFilter.java

  22 
vote

private AffineTransform findTranslation(AffineTransform at,BufferedImage bi){
  if (bi == null)   return null;
  Point2D p2din, p2dout;
  p2din=new Point2D.Double(0.0,0.0);
  p2dout=at.transform(p2din,null);
  double ytrans=p2dout.getY();
  p2din=new Point2D.Double(0,bi.getHeight());
  p2dout=at.transform(p2din,null);
  double xtrans=p2dout.getX();
  AffineTransform tat=new AffineTransform();
  tat.translate(-xtrans,-ytrans);
  return tat;
}
 

Example 8

From project geolatte-maprenderer, under directory /src/main/java/org/geolatte/maprenderer/java2D/.

Source file: BasicLabelRect.java

  22 
vote

public Rectangle2D getBounds(){
  Rectangle2D bounds=layout.getBounds();
  double scl=Math.sqrt(bounds.getHeight() * bounds.getWidth()) * SCALE_FACTOR;
  Point2D pt=getUL();
  bounds.setRect(bounds.getX() + pt.getX() - scl,bounds.getY() + pt.getY() - scl,bounds.getWidth() + scl * 2.0,bounds.getHeight() + scl * 2.0);
  return bounds;
}
 

Example 9

From project gitblit, under directory /src/com/gitblit/client/.

Source file: HeaderPanel.java

  22 
vote

@Override public void paintComponent(Graphics oldG){
  Graphics2D g=(Graphics2D)oldG;
  Point2D startPoint=new Point2D.Float(0,0);
  Point2D endPoint=new Point2D.Float(0,getHeight());
  Paint gradientPaint=new GradientPaint(startPoint,lightColor,endPoint,getBackground(),false);
  g.setPaint(gradientPaint);
  g.fill(new Rectangle2D.Double(0,0,getWidth(),getHeight()));
  g.setColor(new Color(0xff,0x99,0x00));
  int stroke=2;
  g.setStroke(new BasicStroke(stroke));
  g.drawLine(0,getHeight() - 1,getWidth(),getHeight() - 1);
}
 

Example 10

From project GraphLab, under directory /src/graphlab/plugins/visualization/hierarchical/.

Source file: BendedTrees.java

  22 
vote

public void reshapeAllEdges(){
  Iterator<Edge> ei=graph.edgeIterator();
  for (; ei.hasNext(); ) {
    Edge e=ei.next();
    Point2D d1=vertexPlaces.get(e.target);
    Point2D d2=vertexPlaces.get(e.source);
    Vector<Point2D> bendPoints=new Vector<Point2D>();
    bendPoints.add(new Point2D.Double(d1.getX(),d1.getY() - 15));
    bendPoints.add(new Point2D.Double(d2.getX(),d2.getY() + 15));
    edgeBendPoints.put(e,bendPoints);
  }
}
 

Example 11

From project GraphWalker, under directory /src/main/java/org/graphwalker/GUI/.

Source file: App.java

  22 
vote

private void centerOnVertex(){
  Vertex v=mbt.getCurrentVertex();
  if (v != null) {
    Point2D target=getVv().getGraphLayout().transform(v);
    Point2D current=vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
    double dx=current.getX() - target.getX();
    double dy=current.getY() - target.getY();
    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx,dy);
  }
}
 

Example 12

From project iee, under directory /org.eclipse.iee.sample.graph/src/org/jfree/experimental/chart/swt/.

Source file: ChartComposite.java

  22 
vote

/** 
 * Returns the data area (the area inside the axes) for the plot or subplot, with the current scaling applied.
 * @param x  the x-coordinate (for subplot selection).
 * @param y  the y-coordinate (for subplot selection).
 * @return The scaled data area.
 */
public Rectangle getScreenDataArea(int x,int y){
  PlotRenderingInfo plotInfo=this.info.getPlotInfo();
  Rectangle result;
  if (plotInfo.getSubplotCount() == 0)   result=getScreenDataArea();
 else {
    Point2D selectOrigin=translateScreenToJava2D(new Point(x,y));
    int subplotIndex=plotInfo.getSubplotIndex(selectOrigin);
    if (subplotIndex == -1) {
      return null;
    }
    result=scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea());
  }
  return result;
}
 

Example 13

From project jagger, under directory /diagnostics/src/main/java/com/griddynamics/jagger/diagnostics/visualization/.

Source file: GraphVisualizationHelper.java

  22 
vote

private static <V,E>Layout<V,E> displacementLayout(Layout<V,E> layout,final int xOffset,final int yOffset){
  return new LayoutDecorator<V,E>(layout){
    @Override public Point2D transform(    V v){
      Point2D point=delegate.transform(v);
      return new Point.Double(point.getX() + xOffset,point.getY() + yOffset);
    }
  }
;
}
 

Example 14

From project jgraphx, under directory /src/com/mxgraph/util/svg/.

Source file: AWTPathProducer.java

  22 
vote

/** 
 * Implements  {@link PathHandler#closePath()}.
 */
public void closePath() throws ParseException {
  path.closePath();
  Point2D pt=path.getCurrentPoint();
  currentX=(float)pt.getX();
  currentY=(float)pt.getY();
}
 

Example 15

From project joshua, under directory /src/joshua/ui/hypergraph_visualizer/.

Source file: HyperGraphTransformer.java

  22 
vote

public Point2D transform(Vertex v){
  double x, y;
  Point2D treePosition=graphTree.transform(v);
  x=treePosition.getX();
  y=Y_BASELINE - Y_DIST * distanceToLeaf(v);
  return new Point2D.Double(x,y);
}
 

Example 16

From project lpped, under directory /src/ccs/.

Source file: CCSystem.java

  22 
vote

private void drawPoint(Graphics2D g2d,CCSPoint ccsp){
  Point2D p2d=new Point2D.Double(ccsp.x,ccsp.y);
  Point p=translate(p2d);
  g2d.setColor(ccsp.color);
  Ellipse2D r2d=new Ellipse2D.Double(p.x - 3,p.y - 3,6,6);
  if (ccsp.fill)   g2d.fill(r2d);
 else   g2d.draw(r2d);
}
 

Example 17

From project mobilis, under directory /MobilisXHunt/MobilisXHunt_MapEditor/src/de/tudresden/inf/rn/mobilis/android/xhunt/mapeditor/view/.

Source file: MainView.java

  22 
vote

/** 
 * Do paint waypoints.
 * @param waypoints the waypoints
 * @param map the map
 */
private void doPaintWaypoints(Set<Waypoint> waypoints,JXMapViewer map){
  Rectangle rect=map.getViewportBounds();
  for (  Waypoint wp : waypoints) {
    Point2D point2D=map.getTileFactory().geoToPixel(wp.getPosition(),map.getZoom());
    Point currentPoint=new Point((int)point2D.getX() - rect.x,(int)point2D.getY() - rect.y);
    JComponent component=((WaypointStation)wp).getPanel();
    currentPoint.x-=(component.getWidth() / 2);
    currentPoint.y-=(component.getHeight() / 2);
    component.setLocation(currentPoint);
  }
}
 

Example 18

From project nodebox, under directory /src/main/java/nodebox/client/.

Source file: NetworkView.java

  22 
vote

public void mouseMoved(MouseEvent e){
  Point2D pt=inverseViewTransformPoint(e.getPoint());
  overOutput=getNodeWithOutputPortAt(pt);
  overInput=getInputPortAt(pt);
  repaint();
}
 

Example 19

From project beam-third-party, under directory /mssl-stereomatcher/src/main/java/uk/ac/ucl/mssl/climatephysics/imaging/.

Source file: GaussianKernelFixedSize.java

  21 
vote

protected float[] computeData(int size,float sigma){
  final double eds2p=1.0 / Math.sqrt(2.0 * Math.PI);
  float[] data=new float[size * size];
  Point2D centre=new Point2D.Float(size / 2,size / 2);
  double total=0.0d;
  for (int x=0; x < size; x++) {
    for (int y=0; y < size; y++) {
      double euclidianDistance=centre.distance(new Point2D.Float(x,y));
      double temp=-1.0 * (euclidianDistance * euclidianDistance) / (2.0 * sigma * sigma);
      double value=(eds2p / sigma * Math.exp(temp));
      total+=value;
      data[x * size + y]=(float)value;
    }
  }
  for (int x=0; x < data.length; x++) {
    data[x]/=total;
  }
  return data;
}
 

Example 20

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.specmol/src/net/bioclipse/specmol/listeners/.

Source file: PeakChartCompositeMouseListener.java

  21 
vote

public void mouseClicked(java.awt.event.MouseEvent arg0){
  if (!page.getFocus()) {
    page.setFocus();
  }
  SpokChartPanel chartPanel=page.getPeakChartcomposite().getChartPanel();
  Point2D p=chartPanel.translateScreenToJava2D(arg0.getPoint());
  XYPlot plot=(XYPlot)chartPanel.getChart().getPlot();
  ChartRenderingInfo info=chartPanel.getChartRenderingInfo();
  Rectangle2D dataArea=info.getPlotInfo().getDataArea();
  double xx=plot.getDomainAxis().java2DToValue(p.getX(),dataArea,plot.getDomainAxisEdge());
  XYDataset dataSet=plot.getDataset();
  double nearestValue=xx;
  double diff=1000000;
  for (int j=0; j < dataSet.getSeriesCount(); j++) {
    for (int i=0; i < dataSet.getItemCount(j); i++) {
      double value=dataSet.getXValue(j,i);
      double newDiff=Math.abs(xx - value);
      if (diff == 1000000) {
        diff=Math.abs(xx - value);
        nearestValue=value;
      }
      if (newDiff < diff) {
        nearestValue=value;
        diff=newDiff;
      }
    }
  }
  ArrayList<CMLPeak> peaks=new ArrayList<CMLPeak>();
  Iterator<CMLPeak> peakIt=page.getCurrentSpectrum().getPeakListElements().get(0).getPeakElements().iterator();
  while (peakIt.hasNext()) {
    CMLPeak peak=peakIt.next();
    if (peak.getXValue() == nearestValue) {
      peaks.add(peak);
      break;
    }
  }
  page.getAssignmentController().setSelection(peaks,null);
}
 

Example 21

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/.

Source file: Java2DOutputDevice.java

  21 
vote

private void drawSelectedText(RenderingContext c,InlineText inlineText,InlineLayoutBox iB,FSGlyphVector glyphVector){
  GlyphVector vector=((AWTFSGlyphVector)glyphVector).getGlyphVector();
  for (int i=0; i < inlineText.getSelectionStart(); i++) {
    vector.setGlyphPosition(i,new Point2D.Float(-100000,-100000));
  }
  for (int i=inlineText.getSelectionEnd(); i < inlineText.getSubstring().length(); i++) {
    vector.setGlyphPosition(i,new Point2D.Float(-100000,-100000));
  }
  if (inlineText.getParent().getStyle().isTextJustify()) {
    JustificationInfo info=inlineText.getParent().getLineBox().getJustificationInfo();
    if (info != null) {
      String string=inlineText.getSubstring();
      float adjust=0.0f;
      for (int i=inlineText.getSelectionStart(); i < inlineText.getSelectionEnd(); i++) {
        char ch=string.charAt(i);
        if (i != 0) {
          Point2D point=vector.getGlyphPosition(i);
          vector.setGlyphPosition(i,new Point2D.Double(point.getX() + adjust,point.getY()));
        }
        if (ch == ' ' || ch == '\u00a0' || ch == '\u3000') {
          adjust+=info.getSpaceAdjust();
        }
 else {
          adjust+=info.getNonSpaceAdjust();
        }
      }
    }
  }
  c.getTextRenderer().drawGlyphVector(c.getOutputDevice(),glyphVector,iB.getAbsX() + inlineText.getX(),iB.getAbsY() + iB.getBaseline());
}
 

Example 22

From project glg2d, under directory /src/main/java/glg2d/impl/shader/text/.

Source file: GL2ES2TextDrawer.java

  21 
vote

protected void drawChars(char[] string,float x,float y){
  pipeline.use(gl,true);
  pipeline.setColor(gl,g2d.getUniformsObject().colorHook.getRGBA());
  pipeline.setTransform(gl,g2d.getUniformsObject().transformHook.getGLMatrixData());
  pipeline.bindBuffer(gl);
  GlyphVector glyphs=getFont().createGlyphVector(getFontRenderContext(),string);
  for (int i=0; i < string.length; i++) {
    Triangles triangles=getTesselatedGlyph(string[i]);
    Point2D pt=glyphs.getGlyphPosition(i);
    pipeline.setLocation(gl,(float)pt.getX() + x,(float)pt.getY() + y);
    triangles.draw(gl);
  }
  pipeline.unbindBuffer(gl);
  pipeline.use(gl,false);
}
 

Example 23

From project Graph-Explorer, under directory /src/com/vaadin/graph/.

Source file: LayoutEngine.java

  21 
vote

static void layout(Graph<NodeProxy,ArcProxy> graph,final int width,final int height,Collection<NodeProxy> lockedNodes){
  Dimension size=new Dimension(width,height);
  FRLayout<NodeProxy,ArcProxy> layout=new FRLayout<NodeProxy,ArcProxy>(graph,size);
  layout.lock(false);
  for (  NodeProxy v : lockedNodes) {
    layout.lock(v,true);
  }
  layout.setInitializer(new Transformer<NodeProxy,Point2D>(){
    public Point2D transform(    NodeProxy input){
      int x=input.getX();
      int y=input.getY();
      return new Point2D.Double(x == -1 ? new Random().nextInt(width) : x,y == -1 ? new Random().nextInt(height) : y);
    }
  }
);
  layout.initialize();
  while (!layout.done()) {
    layout.step();
  }
  for (  NodeProxy v : graph.getVertices()) {
    Point2D location=layout.transform(v);
    v.setX((int)location.getX());
    v.setY((int)location.getY());
  }
}
 

Example 24

From project maple-ide, under directory /core/src/processing/core/.

Source file: PShapeSVG.java

  21 
vote

public LinearGradient(PShapeSVG parent,XMLElement properties){
  super(parent,properties);
  this.x1=properties.getFloatAttribute("x1");
  this.y1=properties.getFloatAttribute("y1");
  this.x2=properties.getFloatAttribute("x2");
  this.y2=properties.getFloatAttribute("y2");
  String transformStr=properties.getStringAttribute("gradientTransform");
  if (transformStr != null) {
    float t[]=parseMatrix(transformStr).get(null);
    this.transform=new AffineTransform(t[0],t[3],t[1],t[4],t[2],t[5]);
    Point2D t1=transform.transform(new Point2D.Float(x1,y1),null);
    Point2D t2=transform.transform(new Point2D.Float(x2,y2),null);
    this.x1=(float)t1.getX();
    this.y1=(float)t1.getY();
    this.x2=(float)t2.getX();
    this.y2=(float)t2.getY();
  }
}
 

Example 25

From project mididuino, under directory /editor/core/src/processing/core/.

Source file: PShapeSVG.java

  21 
vote

public LinearGradient(PShapeSVG parent,XMLElement properties){
  super(parent,properties);
  this.x1=properties.getFloatAttribute("x1");
  this.y1=properties.getFloatAttribute("y1");
  this.x2=properties.getFloatAttribute("x2");
  this.y2=properties.getFloatAttribute("y2");
  String transformStr=properties.getStringAttribute("gradientTransform");
  if (transformStr != null) {
    float t[]=parseMatrix(transformStr).get(null);
    this.transform=new AffineTransform(t[0],t[3],t[1],t[4],t[2],t[5]);
    Point2D t1=transform.transform(new Point2D.Float(x1,y1),null);
    Point2D t2=transform.transform(new Point2D.Float(x2,y2),null);
    this.x1=(float)t1.getX();
    this.y1=(float)t1.getY();
    this.x2=(float)t2.getX();
    this.y2=(float)t2.getY();
  }
}
 

Example 26

From project movsim, under directory /viewer/src/main/java/org/movsim/viewer/graphics/.

Source file: TrafficCanvasMouseListener.java

  21 
vote

@Override public void mouseMoved(MouseEvent e){
  if (trafficCanvas.isStopped() || trafficCanvas.isPaused()) {
    if (trafficCanvas.vehicleTipWindow == null) {
      trafficCanvas.vehicleTipWindow=new VehicleTipWindow(trafficCanvas,SwingHelper.getFrame(trafficCanvas));
    }
    final Point point=e.getPoint();
    final Point2D transformedPoint=new Point2D.Float();
    final GeneralPath path=new GeneralPath();
    try {
      trafficCanvas.transform.inverseTransform(new Point2D.Float(point.x,point.y),transformedPoint);
    }
 catch (    final NoninvertibleTransformException e1) {
      e1.printStackTrace();
      return;
    }
    final double simulationTime=trafficCanvas.simulationRunnable.simulationTime();
    for (    final RoadSegment roadSegment : roadNetwork) {
      final RoadMapping roadMapping=roadSegment.roadMapping();
      for (      final Vehicle vehicle : roadSegment) {
        final RoadMapping.PolygonFloat polygon=roadMapping.mapFloat(vehicle,simulationTime);
        path.reset();
        path.moveTo(polygon.xPoints[0],polygon.yPoints[0]);
        path.lineTo(polygon.xPoints[1],polygon.yPoints[1]);
        path.lineTo(polygon.xPoints[2],polygon.yPoints[2]);
        path.lineTo(polygon.xPoints[3],polygon.yPoints[3]);
        path.closePath();
        if (path.contains(transformedPoint)) {
          if (trafficCanvas.vehiclePopup == null || trafficCanvas.vehiclePopup.getId() != vehicle.getId()) {
            trafficCanvas.lastVehicleViewed=vehicle.getId();
            trafficCanvas.vehicleTipWindow.setVisible(false);
            trafficCanvas.vehicleTipWindow.show(point,vehicle);
          }
          break;
        }
      }
    }
  }
}
 

Example 27

From project ardverk-dht, under directory /components/tools/src/main/java/org/ardverk/dht/ui/.

Source file: JuicePainter.java

  19 
vote

public boolean paint(Point2D.Double localhost,double width,double height,double radius,Graphics2D g2){
  double cx=width / 2d;
  double cy=height / 2d;
  double fi=position(contactId,2d * Math.PI) - Math.PI / 2d;
  double dx=cx + radius * Math.cos(fi);
  double dy=cy + radius * Math.sin(fi);
  remote.setLocation(dx,dy);
  Point2D.Double corner=new Point2D.Double(localhost.x + 3 * dot.width,localhost.y + 3 * dot.height);
  this.prxDot.setFrameFromCenter(localhost,corner);
  Shape shape=null;
  if (!prxDot.contains(remote)) {
    point.setLocation(cx + noise,cy + noise);
    curve.setCurve(localhost,point,remote);
    shape=curve;
  }
 else {
    double r=radius();
    point.setLocation(localhost.x + r,localhost.y + r);
    circle.setFrameFromCenter(localhost,point);
    shape=circle;
  }
  if (shape != null) {
    g2.setStroke(stroke);
    g2.setColor(PainterUtils.alpha(color,alpha()));
    g2.draw(shape);
  }
  return System.currentTimeMillis() - creationTime >= PainterUtils.DURATION;
}
 

Example 28

From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/demo/.

Source file: DrawingCanvas.java

  19 
vote

@Override protected void paintComponent(Graphics g){
  Graphics2D g2=(Graphics2D)g;
  g2.setColor(Color.WHITE);
  g2.fillRect(0,0,getWidth(),getHeight());
  g2.setColor(Color.BLACK);
  for (  Line2D line : model.getLines()) {
    g2.draw(line);
  }
  for (  Point2D point : model.getPoints()) {
    g2.fillOval((int)point.getX(),(int)point.getY(),5,5);
  }
}
 

Example 29

From project formic, under directory /src/java/net/java/swingfx/waitwithstyle/.

Source file: SingleComponentInfiniteProgress.java

  19 
vote

/** 
 * Builds the circular shape and returns the result as an array of <code>Area</code>. Each <code>Area</code> is one of the bars composing the shape.
 */
private static Area[] buildTicker(int i_iBarCount){
  Area[] ticker=new Area[i_iBarCount];
  Point2D.Double center=new Point2D.Double(0,0);
  double fixedAngle=2.0 * Math.PI / ((double)i_iBarCount);
  for (double i=0.0; i < (double)i_iBarCount; i++) {
    Area primitive=buildPrimitive();
    AffineTransform toCenter=AffineTransform.getTranslateInstance(center.getX(),center.getY());
    AffineTransform toBorder=AffineTransform.getTranslateInstance(UNSCALED_BAR_SIZE,-6.0);
    AffineTransform toCircle=AffineTransform.getRotateInstance(-i * fixedAngle,center.getX(),center.getY());
    AffineTransform toWheel=new AffineTransform();
    toWheel.concatenate(toCenter);
    toWheel.concatenate(toBorder);
    primitive.transform(toWheel);
    primitive.transform(toCircle);
    ticker[(int)i]=primitive;
  }
  return ticker;
}
 

Example 30

From project freemind, under directory /freemind/freemind/view/mindmapview/.

Source file: SharpBezierEdgeView.java

  19 
vote

private void update(){
  float zoom=getMap().getZoom();
  float xctrlRelative=XCTRL * zoom;
  if (getTarget().isLeft()) {
    one=new Point2D.Float(start.x - xctrlRelative,start.y);
    two=new Point2D.Float(end.x + xctrlRelative,end.y);
  }
 else {
    one=new Point2D.Float(start.x + xctrlRelative,start.y);
    two=new Point2D.Float(end.x - xctrlRelative,end.y);
  }
  float w=(getWidth() / 2f + 1) * zoom;
  float w2=w / 2;
  line1.setCurve(start.x - deltaX,start.y - deltaY,one.x - deltaX,one.y - deltaY,two.x,two.y - w2,end.x,end.y);
  line2.setCurve(end.x,end.y,two.x,two.y + w2,one.x + deltaX,one.y + deltaY,start.x + deltaX,start.y + deltaY);
  graph.reset();
  graph.append(line1,true);
  graph.append(line2,true);
  graph.closePath();
}
 

Example 31

From project GAIL, under directory /src/gail/graph/.

Source file: Arc2DX.java

  19 
vote

public static Point2D.Float getCircleCenter(Point2D.Float a,Point2D.Float b,Point2D.Float c){
  float ax=a.x;
  float ay=a.y;
  float bx=b.x;
  float by=b.y;
  float cx=c.x;
  float cy=c.y;
  float A=bx - ax;
  float B=by - ay;
  float C=cx - ax;
  float D=cy - ay;
  float E=A * (ax + bx) + B * (ay + by);
  float F=C * (ax + cx) + D * (ay + cy);
  float G=2 * (A * (cy - by) - B * (cx - bx));
  if (G == 0.0)   return null;
  float px=(D * E - B * F) / G;
  float py=(A * F - C * E) / G;
  return new Point2D.Float(px,py);
}
 

Example 32

From project Game_3, under directory /java/src/playn/java/.

Source file: JavaGradient.java

  19 
vote

static JavaGradient createLinear(float x0,float y0,float x1,float y1,float[] positions,int[] colors){
  Point2D.Float start=new Point2D.Float(x0,y0);
  Point2D.Float end=new Point2D.Float(x1,y1);
  Color[] javaColors=convertColors(colors);
  LinearGradientPaint p=new LinearGradientPaint(start,end,positions,javaColors);
  return new JavaGradient(p);
}
 

Example 33

From project GeoBI, under directory /print/src/main/java/org/mapfish/print/map/renderers/.

Source file: BitmapTileRenderer.java

  19 
vote

private boolean isTileVisible(float x,float y,long w,long h,AffineTransform bitmapTransformer,Transformer transformer){
  GeometryFactory gf=new GeometryFactory();
  Polygon page=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY())}),null);
  Point2D.Float ll=new Point2D.Float();
  Point2D.Float lr=new Point2D.Float();
  Point2D.Float ur=new Point2D.Float();
  Point2D.Float ul=new Point2D.Float();
  bitmapTransformer.transform(new Point2D.Float(x,y),ll);
  bitmapTransformer.transform(new Point2D.Float(x + w,y),lr);
  bitmapTransformer.transform(new Point2D.Float(x + w,y + h),ur);
  bitmapTransformer.transform(new Point2D.Float(x,y + h),ul);
  Polygon tile=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(ll.getX(),ll.getY()),new Coordinate(lr.getX(),lr.getY()),new Coordinate(ur.getX(),ur.getY()),new Coordinate(ul.getX(),ul.getY()),new Coordinate(ll.getX(),ll.getY())}),null);
  return page.intersects(tile);
}
 

Example 34

From project gs-core, under directory /src/org/graphstream/ui/swingViewer/basicRenderer/.

Source file: SpriteRenderer.java

  19 
vote

@Override protected void renderElement(StyleGroup group,Graphics2D g,Camera camera,GraphicElement element){
  GraphicSprite sprite=(GraphicSprite)element;
  Point2D.Double pos=((DefaultCamera)camera).getSpritePosition(sprite,new Point2D.Double(),StyleConstants.Units.GU);
  shape.setFrame(pos.x - w2,pos.y - h2,width,height);
  g.fill(shape);
  renderText(group,g,camera,element);
}
 

Example 35

From project gxa, under directory /atlas-utils/src/main/java/uk/ac/ebi/gxa/anatomogram/svgutil/.

Source file: SvgUtil.java

  19 
vote

public static Collection<Point2D.Float> getArea(Element element){
  final List<Point2D.Float> points=new ArrayList<Point2D.Float>();
  if ("rect".equalsIgnoreCase(element.getTagName())) {
    float x=Float.parseFloat(element.getAttribute("x"));
    float y=Float.parseFloat(element.getAttribute("y"));
    float width=Float.parseFloat(element.getAttribute("width"));
    float height=Float.parseFloat(element.getAttribute("height"));
    points.add(new Point2D.Float(x,y));
    points.add(new Point2D.Float(x + width,y));
    points.add(new Point2D.Float(x + width,y + height));
    points.add(new Point2D.Float(x,y + height));
    points.add(new Point2D.Float(x,y));
  }
 else   if ("path".equalsIgnoreCase(element.getTagName())) {
    parseElement(element,new PathWalker(){
      @Override protected void visit(      float x,      float y){
        points.add(new Point2D.Float(x,y));
      }
    }
);
  }
  return points;
}
 

Example 36

From project hecl, under directory /midp20gui/org/graphics/.

Source file: Drawable.java

  19 
vote

public void drawArc(Point2D p,Dimension d,int startAngle,int arcAngle,boolean filled){
  int x=toX(p);
  int y=toY(p);
  if (filled)   g.fillArc(x,y,d.width,d.height,startAngle,arcAngle);
  g.drawArc(x,y,d.width,d.height,startAngle,arcAngle);
  this.needflush=true;
}
 

Example 37

From project ISAcreator, under directory /src/main/java/org/isatools/isacreator/effects/.

Source file: SmallLoader.java

  19 
vote

/** 
 * Builds the circular shape and returns the result as an array of <code>Area</code>. Each <code>Area</code> is one of the bars composing the shape.
 * @return Array of areas
 */
private Area[] buildTicker(){
  Area[] ticker=new Area[barsCount];
  Point2D.Double center=new Point2D.Double((double)getWidth() / 2,(double)getHeight() / 2);
  double fixedAngle=(2.0 * Math.PI) / ((double)barsCount);
  for (double i=0.0; i < (double)barsCount; i++) {
    Area primitive=buildPrimitive();
    AffineTransform toCenter=AffineTransform.getTranslateInstance(center.getX(),center.getY());
    AffineTransform toBorder=AffineTransform.getTranslateInstance(2.0,-2.0);
    AffineTransform toCircle=AffineTransform.getRotateInstance(-i * fixedAngle,center.getX(),center.getY());
    AffineTransform toWheel=new AffineTransform();
    toWheel.concatenate(toCenter);
    toWheel.concatenate(toBorder);
    primitive.transform(toWheel);
    primitive.transform(toCircle);
    ticker[(int)i]=primitive;
  }
  return ticker;
}
 

Example 38

From project ISAvalidator-ISAconverter-BIImanager, under directory /val_conv_manager_gui/src/main/java/org/isatools/effects/.

Source file: SmallLoader.java

  19 
vote

/** 
 * Builds the circular shape and returns the result as an array of <code>Area</code>. Each <code>Area</code> is one of the bars composing the shape.
 * @return Array of areas
 */
private Area[] createTicker(){
  Area[] ticker=new Area[barsCount];
  Point2D.Double center=new Point2D.Double((double)getWidth() / 2,(double)getHeight() / 2);
  double fixedAngle=(2.0 * Math.PI) / ((double)barsCount);
  for (double i=0.0; i < (double)barsCount; i++) {
    Area primitive=createArea();
    AffineTransform toCenter=AffineTransform.getTranslateInstance(center.getX(),center.getY());
    AffineTransform toBorder=AffineTransform.getTranslateInstance(2.0,-2.0);
    AffineTransform toCircle=AffineTransform.getRotateInstance(-i * fixedAngle,center.getX(),center.getY());
    AffineTransform toWheel=new AffineTransform();
    toWheel.concatenate(toCenter);
    toWheel.concatenate(toBorder);
    primitive.transform(toWheel);
    primitive.transform(toCircle);
    ticker[(int)i]=primitive;
  }
  return ticker;
}
 

Example 39

From project jbpm-plugin, under directory /jbpm/src/main/java/hudson/jbpm/rendering/.

Source file: GraphicsUtil.java

  19 
vote

public static boolean getLineRectangleIntersection(Rectangle2D.Double rect,Line2D.Double line,Point2D.Double intersection){
  Line2D.Double top=new Line2D.Double(rect.x,rect.y,rect.x + rect.width,rect.y);
  Line2D.Double bottom=new Line2D.Double(rect.x,rect.y + rect.height,rect.x + rect.width,rect.y + rect.height);
  Line2D.Double left=new Line2D.Double(rect.x,rect.y,rect.x,rect.y + rect.height);
  Line2D.Double right=new Line2D.Double(rect.x + rect.width,rect.y,rect.x + rect.width,rect.y + rect.height);
  return getLineLineIntersection(line,top,intersection) || getLineLineIntersection(line,bottom,intersection) || getLineLineIntersection(line,left,intersection)|| getLineLineIntersection(line,right,intersection);
}
 

Example 40

From project jchempaint, under directory /src/main/org/openscience/jchempaint/controller/.

Source file: AbstractSelectModule.java

  19 
vote

public void mouseDrag(Point2d from,Point2d to){
  Rectangle2D bounds=null;
  boolean inSelectionCircle=false;
  IChemObjectSelection sel=chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
  double d=chemModelRelay.getRenderer().getRenderer2DModel().getSelectionRadius() / chemModelRelay.getRenderer().getRenderer2DModel().getScale();
  if (from.equals(startPoint)) {
    if (sel != null && sel.isFilled()) {
      bounds=BoundsCalculator.calculateBounds(sel.getConnectedAtomContainer());
      IAtom closestAtom=getClosestSelAtom(startPoint);
      inSelectionCircle=closestAtom.getPoint2d().distance(startPoint) < 4 * d;
    }
    if ((bounds != null && bounds.contains(new Point2D.Double(startPoint.x,startPoint.y))) || inSelectionCircle) {
      IControllerModule newActiveModule=new MoveModule(this.chemModelRelay,this);
      newActiveModule.setID("move");
      chemModelRelay.setActiveDrawModule(newActiveModule);
      Point2d sf=chemModelRelay.getRenderer().toScreenCoordinates(startPoint.x,startPoint.y);
      Point2d st=chemModelRelay.getRenderer().toScreenCoordinates(to.x,to.y);
      ((IMouseEventRelay)this.chemModelRelay).mouseDrag((int)sf.x,(int)sf.y,(int)st.x,(int)st.y);
      return;
    }
  }
  this.selection.addPoint(to);
  this.chemModelRelay.select(selection);
  this.chemModelRelay.getRenderer().getRenderer2DModel().setSelection(this.selection);
  this.chemModelRelay.updateView();
}
 

Example 41

From project LTE-Simulator, under directory /src/rs/etf/igor/.

Source file: eNodeB.java

  19 
vote

/** 
 * Constructor
 * @param xCo
 * @param yCo
 * @param alpha
 * @param beta
 * @param gamma
 * @param delta
 * @param id
 */
public eNodeB(double xCo,double yCo,double alpha,double beta,double gamma,double delta,int id){
  x=xCo;
  y=yCo;
  this.id=id;
  this.setAlpha(alpha);
  this.setBeta(beta);
  this.setGamma(gamma);
  this.setDelta(delta);
  for (int j=0; j < 6; j++) {
switch (j) {
case 0:
      boundries.add(new Point2D.Double(x + R,y));
    break;
case 1:
  boundries.add(new Point2D.Double(x + R / 2,y + R * Math.sqrt(3) / 2));
break;
case 2:
boundries.add(new Point2D.Double(x - R / 2,y + R * Math.sqrt(3) / 2));
break;
case 3:
boundries.add(new Point2D.Double(x - R,y));
break;
case 4:
boundries.add(new Point2D.Double(x - R / 2,y - R * Math.sqrt(3) / 2));
break;
case 5:
boundries.add(new Point2D.Double(x + R / 2,y - R * Math.sqrt(3) / 2));
break;
}
}
for (int j=0; j < NoSECTORS; j++) {
mySectors.add(new Sector(j,this));
}
}
 

Example 42

From project mapfish-print, under directory /src/main/java/org/mapfish/print/map/renderers/.

Source file: BitmapTileRenderer.java

  19 
vote

private boolean isTileVisible(float x,float y,long w,long h,AffineTransform bitmapTransformer,Transformer transformer){
  GeometryFactory gf=new GeometryFactory();
  Polygon page=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY())}),null);
  Point2D.Float ll=new Point2D.Float();
  Point2D.Float lr=new Point2D.Float();
  Point2D.Float ur=new Point2D.Float();
  Point2D.Float ul=new Point2D.Float();
  bitmapTransformer.transform(new Point2D.Float(x,y),ll);
  bitmapTransformer.transform(new Point2D.Float(x + w,y),lr);
  bitmapTransformer.transform(new Point2D.Float(x + w,y + h),ur);
  bitmapTransformer.transform(new Point2D.Float(x,y + h),ul);
  Polygon tile=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(ll.getX(),ll.getY()),new Coordinate(lr.getX(),lr.getY()),new Coordinate(ur.getX(),ur.getY()),new Coordinate(ul.getX(),ul.getY()),new Coordinate(ll.getX(),ll.getY())}),null);
  return page.intersects(tile);
}
 

Example 43

From project mapfish-print_1, under directory /src/main/java/org/mapfish/print/map/renderers/.

Source file: BitmapTileRenderer.java

  19 
vote

private boolean isTileVisible(float x,float y,long w,long h,AffineTransform bitmapTransformer,Transformer transformer){
  GeometryFactory gf=new GeometryFactory();
  Polygon page=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY()),new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY() + transformer.getPaperH()),new Coordinate(transformer.getPaperPosX(),transformer.getPaperPosY())}),null);
  Point2D.Float ll=new Point2D.Float();
  Point2D.Float lr=new Point2D.Float();
  Point2D.Float ur=new Point2D.Float();
  Point2D.Float ul=new Point2D.Float();
  bitmapTransformer.transform(new Point2D.Float(x,y),ll);
  bitmapTransformer.transform(new Point2D.Float(x + w,y),lr);
  bitmapTransformer.transform(new Point2D.Float(x + w,y + h),ur);
  bitmapTransformer.transform(new Point2D.Float(x,y + h),ul);
  Polygon tile=gf.createPolygon(gf.createLinearRing(new Coordinate[]{new Coordinate(ll.getX(),ll.getY()),new Coordinate(lr.getX(),lr.getY()),new Coordinate(ur.getX(),ur.getY()),new Coordinate(ul.getX(),ul.getY()),new Coordinate(ll.getX(),ll.getY())}),null);
  return page.intersects(tile);
}
 

Example 44

From project mdk, under directory /io/xml-parsers/src/main/java/uk/ac/ebi/mdk/io/xml/kgml/.

Source file: KGMLGraphics.java

  19 
vote

public KGMLGraphics(String name,Color foreground,Color background,Point2D coordinates){
  this.name=name;
  this.foreground=foreground;
  this.background=background;
  this.point=coordinates;
}
 

Example 45

From project nenya, under directory /core/src/main/java/com/threerings/geom/.

Source file: GeomUtil.java

  19 
vote

/** 
 * Calculate the intersection of two lines. Either line may be considered as a line segment, and the intersecting point is only considered valid if it lies upon the segment.  Note that Point extends Point2D.
 * @param p1 and p2 the coordinates of the first line.
 * @param seg1 if the first line should be considered a segment.
 * @param p3 and p4 the coordinates of the second line.
 * @param seg2 if the second line should be considered a segment.
 * @param result the point that will be filled in with the intersecting point.
 * @return true if result was filled in, or false if the lines are parallel or the point ofintersection lies outside of a segment.
 */
public static boolean lineIntersection(Point2D p1,Point2D p2,boolean seg1,Point2D p3,Point2D p4,boolean seg2,Point2D result){
  double y43=p4.getY() - p3.getY();
  double x21=p2.getX() - p1.getX();
  double x43=p4.getX() - p3.getX();
  double y21=p2.getY() - p1.getY();
  double denom=y43 * x21 - x43 * y21;
  if (denom == 0) {
    return false;
  }
  double y13=p1.getY() - p3.getY();
  double x13=p1.getX() - p3.getX();
  double ua=(x43 * y13 - y43 * x13) / denom;
  if (seg1 && ((ua < 0) || (ua > 1))) {
    return false;
  }
  if (seg2) {
    double ub=(x21 * y13 - y21 * x13) / denom;
    if ((ub < 0) || (ub > 1)) {
      return false;
    }
  }
  double x=p1.getX() + ua * x21;
  double y=p1.getY() + ua * y21;
  result.setLocation(x,y);
  return true;
}
 

Example 46

From project onebusaway-uk, under directory /onebusaway-uk-atco-cif-parser/src/main/java/org/onebusaway/uk/atco_cif/.

Source file: AtcoCifParser.java

  19 
vote

private void parseAdditionalLocation(ContentHandler handler){
  AdditionalLocationElement element=element(new AdditionalLocationElement());
  String transactionType=pop(1);
  element.setLocationId(pop(12));
  String xValue=pop(8);
  String yValue=pop(8);
  Point2D.Double location=getLocation(xValue,yValue,true);
  if (location != null) {
    element.setLat(location.y);
    element.setLon(location.x);
  }
  fireElement(element,handler);
}