Package javax.vecmath

Examples of javax.vecmath.Point2d


        JCPAction act = new JCPAction().getAction(panel, "org.openscience.jchempaint.action.ChangeModeAction@select");
        act.actionPerformed(null);
        applet.panel("renderpanel").robot.waitForIdle();
    IAtomContainer ethane = panel.getChemModel().getMoleculeSet().getAtomContainer(0);
    Renderer r = panel.getRenderPanel().getRenderer();
    Point2d atompos0=ethane.getAtom(0).getPoint2d();
    Point2d atompos1=ethane.getAtom(1).getPoint2d();
    atompos0 = r.toScreenCoordinates(atompos0.x, atompos0.y);
    atompos1 = r.toScreenCoordinates(atompos1.x, atompos1.y);
    panel.get2DHub().mouseClickedDown((int)atompos0.x, (int)atompos0.y);
    panel.get2DHub().updateView();
    applet.panel("renderpanel").robot.waitForIdle();
View Full Code Here


        this.g.drawLine(a[0], a[1], b[0], b[1]);
        double arrowWidth = rendererModel.getArrowHeadWidth() / rendererModel.getScale();
        double lenghtOfArrow = Math.sqrt(Math.pow(Math.abs(line.startX - line.endX), 2) + Math.pow(Math.abs(line.startY - line.endY), 2));
        double fractionOfHead = arrowWidth / lenghtOfArrow;
        //headpoint is a line on the arrow arrowWidth away from end
        Point2d headPoint = new Point2d();
        if (line.startX < line.endX)
            headPoint.x = line.startX + (line.endX - line.startX) * (fractionOfHead);
        else
            headPoint.x = line.endX + (line.startX - line.endX) * (1 - fractionOfHead);
        if (line.startY < line.endY)
            headPoint.y = line.startY + (line.endY - line.startY) * (fractionOfHead);
        else
            headPoint.y = line.endY + (line.startY - line.endY) * (1 - fractionOfHead);
        //rotate headpoint in both directions to get end points of arrow
        double relativex = headPoint.x - line.startX;
        double relativey = headPoint.y - line.startY;
        double angle = Math.PI / 6;
        double costheta = Math.cos(angle);
        double sintheta = Math.sin(angle);
        Point2d firstArrowPoint = new Point2d();
        firstArrowPoint.x = relativex * costheta - relativey * sintheta + line.startX;
        firstArrowPoint.y = relativex * sintheta + relativey * costheta + line.startY;
        int[] firstArrowPointCoords = this.transformPoint(firstArrowPoint.x, firstArrowPoint.y);
        this.g.drawLine(a[0], a[1], firstArrowPointCoords[0], firstArrowPointCoords[1]);
        angle = -Math.PI / 6;
        costheta = Math.cos(angle);
        sintheta = Math.sin(angle);
        Point2d secondArrowPoint = new Point2d();
        secondArrowPoint.x = relativex * costheta - relativey * sintheta + line.startX;
        secondArrowPoint.y = relativex * sintheta + relativey * costheta + line.startY;
        int[] secondArrowPointCoords = this.transformPoint(secondArrowPoint.x, secondArrowPoint.y);
        this.g.drawLine(a[0], a[1], secondArrowPointCoords[0], secondArrowPointCoords[1]);
        this.g.setStroke(savedStroke);
View Full Code Here

            new Vector2d(wedge.firstPointY - wedge.secondPointY, wedge.secondPointX - wedge.firstPointX);
        normal.normalize();
        normal.scale(rendererModel.getWedgeWidth() / rendererModel.getScale())
       
        // make the triangle corners
        Point2d vertexA = new Point2d(wedge.firstPointX, wedge.firstPointY);
        Point2d vertexB = new Point2d(wedge.secondPointX, wedge.secondPointY);
        Point2d vertexC = new Point2d(vertexB);
        vertexB.add(normal);
        vertexC.sub(normal);
        this.g.setColor(wedge.color);
        if (wedge.type == WedgeLineElement.TYPE.DASHED) {
            this.drawDashedWedge(vertexA, vertexB, vertexC);
        } else if(wedge.type == WedgeLineElement.TYPE.WEDGED){
            this.drawFilledWedge(vertexA, vertexB, vertexC);
View Full Code Here

        }
    }
   
    public void visit(WigglyLineElement wedge) {
        // make the endpoints
        Point2d vertexA = new Point2d(wedge.firstPointX, wedge.firstPointY);
        Point2d vertexB = new Point2d(wedge.secondPointX, wedge.secondPointY);
        this.g.setColor(wedge.color);
       
        // store the current stroke
        Stroke storedStroke = this.g.getStroke();
        this.g.setStroke(new BasicStroke(1));
       
        // calculate the distances between circles
        double distance = vertexB.distance(vertexA);
        double gapFactor = 0.1;
        double gap = distance * gapFactor;
        double numberOfCircles = distance*5;
       
        int diameter = (int)(rendererModel.getBondLength()*rendererModel.getZoomFactor()*1.2*gapFactor)+2;
        double d = 0;
        double rad=BondTools.giveAngleBothMethods(new Point2d(wedge.firstPointX,wedge.firstPointY), new Point2d(wedge.firstPointX+100,wedge.firstPointY), new Point2d(wedge.secondPointX,wedge.secondPointY), true);
        int degrees=(int)(360*(rad/(2*Math.PI)));
        // draw by interpolating along the imaginary straight line
        for (int i = 0; i < numberOfCircles; i++) {
            Point2d p1 = new Point2d();
            p1.interpolate(vertexA, vertexB, d);
            Point2d p2 = new Point2d();
            p2.interpolate(vertexA, vertexB, d+1/numberOfCircles);
           
            int[] p1T = this.transformPoint(p1.x, p1.y);
            int[] p2T = this.transformPoint(p2.x, p2.y);
            int wh = (int) (new Point2d(p1T[0],p1T[1]).distance(new Point2d(p2T[0],p2T[1])));

            this.g.drawArc(p1T[0]-diameter, p1T[1]-diameter/2, wh,wh, i % 2 == 0 ? degrees : (degrees+180)%360, 180);

            if (distance * (d + gapFactor) >= distance) {
                break;
View Full Code Here

        int[] old=null;
       
        // draw by interpolating along the edges of the triangle
        for (int i = 0; i < numberOfDashes; i++) {
            double d2 = d-gapFactor;
            Point2d p1 = new Point2d();
            p1.interpolate(vertexA, vertexB, d);
            Point2d p2 = new Point2d();
            p2.interpolate(vertexA, vertexC, d2);
            int[] p1T = this.transformPoint(p1.x, p1.y);
            int[] p2T = this.transformPoint(p2.x, p2.y);
            this.g.drawLine(p1T[0], p1T[1], p2T[0], p2T[1]);
            if(old==null)
              old = p2T;
View Full Code Here

       
        if (jcpModel.getShowTooltip() && (atom == model.getHighlightedAtom() ||( model.getExternalSelectedPart()!=null &&  model.getExternalSelectedPart().contains(atom))) && model.getToolTipText(atom) != null)
        {
            String text = model.getToolTipText(atom);
            String[] result = text.split("\\n");
            Point2d p = atom.getPoint2d();
            Color c = Color.black;
            TextGroupElement textGroup;
            if(result.length>1){
                textGroup = new TextGroupElement(p.x, p.y, result[1], c, Color.yellow);
                textGroup.addChild(result[0], TextGroupElement.Position.N);
View Full Code Here

        double numberOfDashes = distance / gap;
        double d = 0;
       
        // draw by interpolating along the edges of the triangle
        for (int i = 0; i < numberOfDashes; i++) {
            Point2d p1 = new Point2d();
            p1.interpolate(vertexA, vertexB, d);
            Point2d p2 = new Point2d();
            p2.interpolate(vertexA, vertexC, d);
            int[] p1T = this.transformPoint(p1.x, p1.y);
            int[] p2T = this.transformPoint(p2.x, p2.y);
            this.g.drawLine(p1T[0], p1T[1], p2T[0], p2T[1]);
            if (distance * (d + gapFactor) >= distance) {
                break;
View Full Code Here

    }
   
    public void visit(PathElement path) {
        this.g.setColor(path.color);
        for (int i = 1; i < path.points.size(); i++) {
            Point2d point1 = path.points.get(i - 1);
            Point2d point2 = path.points.get(i);
            int[] p1 = this.transformPoint(point1.x, point1.y);
            int[] p2 = this.transformPoint(point2.x, point2.y);
            this.g.drawLine(p1[0], p1[1], p2[0], p2[1]);
        }
    }
View Full Code Here

            double d = 4 * r;
            IAtomContainer selectedAC = selection.getConnectedAtomContainer();
            if (selectedAC != null) {
                for (IAtom atom : selectedAC.atoms()) {
                    Point2d p = atom.getPoint2d();
                    IRenderingElement element;
                    element = new OvalElement(
                          p.x, p.y, d, false, selectionColor);
                    selectionElements.add(element);
                }
View Full Code Here

        double modelAtomRadius = ATOM_RADIUS / scale;
        double modelPointRadius = SCREEN_RADIUS / scale;
        double modelSeparation = SCREEN_SEPARATION / scale;
        for (ILonePair lp : ac.lonePairs()) {
            IAtom atom = lp.getAtom();
            Point2d p = atom.getPoint2d();
            int align = GeometryTools.getBestAlignmentForLabelXY(ac, atom);
            double rx = p.x;
            double ry = p.y;
            double dx = 0;
            double dy = 0;
View Full Code Here

TOP

Related Classes of javax.vecmath.Point2d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.