Search in sources :

Example 81 with Point2D

use of java.awt.geom.Point2D in project connection-scan by mobitopp.

the class RoutePoints method startsWith.

private static List<Point2D> startsWith(Stop start, List<Point2D> points) {
    Point2D startLocation = start.coordinate();
    if (points.isEmpty()) {
        return Collections.singletonList(startLocation);
    }
    ArrayList<Point2D> containsStart = new ArrayList<>();
    if (startsNotAt(startLocation, points)) {
        containsStart.add(startLocation);
    }
    containsStart.addAll(points);
    return containsStart;
}
Also used : Point2D(java.awt.geom.Point2D) ArrayList(java.util.ArrayList)

Example 82 with Point2D

use of java.awt.geom.Point2D in project connection-scan by mobitopp.

the class RoutePoints method endsWith.

private static List<Point2D> endsWith(Stop end, List<Point2D> points) {
    Point2D endLocation = end.coordinate();
    if (points.isEmpty()) {
        return Collections.singletonList(endLocation);
    }
    ArrayList<Point2D> containsEnd = new ArrayList<>(points);
    if (endsNotAt(endLocation, points)) {
        containsEnd.add(endLocation);
    }
    return containsEnd;
}
Also used : Point2D(java.awt.geom.Point2D) ArrayList(java.util.ArrayList)

Example 83 with Point2D

use of java.awt.geom.Point2D in project vcell by virtualcell.

the class ODETimePlotMultipleScansPanel method updateScanParamChoices.

/**
 * Insert the method's description here.
 * Creation date: (10/18/2005 12:44:06 AM)
 */
private void updateScanParamChoices() {
    AsynchClientTask task1 = new AsynchClientTask("get ode results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            int[] jobIndexes = scanChoiceTable.getSelectedRows();
            VCSimulationIdentifier vcSimulationIdentifier = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
            int plotCount = jobIndexes.length * variableNames.length;
            SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
            double[][] dataValues = new double[plotCount + 1][];
            PlotData[] plotDatas = new PlotData[plotCount];
            String[] plotNames = new String[plotCount];
            int plotIndex = 0;
            dataValues[0] = null;
            for (int ji = 0; ji < jobIndexes.length; ji++) {
                int jobIndex = jobIndexes[ji];
                final VCDataIdentifier vcdid = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
                ODEDataManager odeDatamanager = ((ODEDataManager) dataManager).createNewODEDataManager(vcdid);
                ODESolverResultSet odeSolverResultSet = odeDatamanager.getODESolverResultSet();
                if (ji == 0) {
                    plotPane.setStepViewVisible(simulation.getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver(), odeSolverResultSet.isMultiTrialData());
                    hashTable.put("bMultiTrial", new Boolean(odeSolverResultSet.isMultiTrialData()));
                }
                double[] tdata = null;
                if (!odeSolverResultSet.isMultiTrialData()) {
                    int tcol = odeSolverResultSet.findColumn(ReservedVariable.TIME.getName());
                    tdata = odeSolverResultSet.extractColumn(tcol);
                    if (dataValues[0] == null) {
                        dataValues[0] = tdata;
                    }
                }
                for (int v = 0; v < variableNames.length; v++) {
                    String varname = variableNames[v];
                    int varcol = odeSolverResultSet.findColumn(varname);
                    double[] vdata = odeSolverResultSet.extractColumn(varcol);
                    if (!odeSolverResultSet.isMultiTrialData()) {
                        dataValues[plotIndex + 1] = vdata;
                        // plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                        plotDatas[plotIndex] = new PlotData(tdata, vdata);
                    // symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    } else {
                        Point2D[] histogram = ODESolverPlotSpecificationPanel.generateHistogram(vdata);
                        double[] x = new double[histogram.length];
                        double[] y = new double[histogram.length];
                        for (int j = 0; j < histogram.length; j++) {
                            x[j] = histogram[j].getX();
                            y[j] = histogram[j].getY();
                        }
                        plotDatas[plotIndex] = new PlotData(x, y);
                    }
                    plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                    symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    plotIndex++;
                }
            }
            hashTable.put("dataValues", dataValues);
            hashTable.put("plotDatas", plotDatas);
            hashTable.put("plotNames", plotNames);
            hashTable.put("symbolTableEntries", symbolTableEntries);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            double[][] dataValues = (double[][]) hashTable.get("dataValues");
            PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
            String[] plotNames = (String[]) hashTable.get("plotNames");
            SymbolTableEntry[] symbolTableEntries = (SymbolTableEntry[]) hashTable.get("symbolTableEntries");
            if (plotDatas == null || plotDatas.length == 0 || (plotDatas.length == 1 && plotDatas[0] == null) || plotNames == null) {
                plotPane.setPlot2D(null);
                return;
            }
            Plot2D plot2D = null;
            if (hashTable.get("bMultiTrial") instanceof Boolean && (Boolean) hashTable.get("bMultiTrial")) {
                plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Probability Distribution of Species", "Number of Particles", "" });
            } else if (simulation.getSolverTaskDescription().getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
                plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
            } else {
                plot2D = new SingleXPlot2D(symbolTableEntries, null, ReservedVariable.TIME.getName(), plotNames, dataValues);
            }
            plotPane.setPlot2D(plot2D);
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Point2D(java.awt.geom.Point2D) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) PlotData(cbit.plot.PlotData) Hashtable(java.util.Hashtable) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SingleXPlot2D(cbit.plot.SingleXPlot2D) ODEDataManager(cbit.vcell.simdata.ODEDataManager) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 84 with Point2D

use of java.awt.geom.Point2D in project vcell by virtualcell.

the class Plot2DPanel method drawHistogram.

// added March 30 to display histogram
private void drawHistogram(PlotData plotData, int index, Graphics2D g, int renderHints, int width) {
    if (plotData != null) {
        g.setStroke(lineBS_15);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        if (plotRectHolder == null || plotRectHolder.x != getLMargin() + getTick() || plotRectHolder.y != getTMargin() + getTick() - (getBCompact() ? 2 : 0) || plotRectHolder.width != getWidth() - 2 * getTick() - getLMargin() - getRMargin() || plotRectHolder.height != getHeight() - 2 * getTick() - getTMargin() - getBMargin() + (getBCompact() ? 4 : 0)) {
            plotRectHolder = new Rectangle(getLMargin() + getTick(), getTMargin() + getTick() - (getBCompact() ? 2 : 0), getWidth() - 2 * getTick() - getLMargin() - getRMargin(), getHeight() - 2 * getTick() - getTMargin() - getBMargin() + (getBCompact() ? 4 : 0));
        }
        g.setClip(plotRectHolder);
        if (plotData != null && plotData.getSize() > 0) {
            nodes[index].setPoints(mapPoints(plotData));
            Point2D[] points = nodes[index].getPoints();
            int w = width;
            if (width % 2 != 0)
                w = w + 1;
            for (int k = 0; k < points.length; k++) {
                double x = points[k].getX() - w / 2;
                double y = points[k].getY();
                // to get transformed coordinate for y0=0, h=y0-y
                Point2D[] transH = new Point2D.Double[1];
                Point2D temp = new Point2D.Double(plotData.getPoints()[k].getX(), 0);
                Point2D[] origH = new Point2D.Double[1];
                origH[0] = temp;
                getTransform().transform(origH, 0, transH, 0, 1);
                double h = transH[0].getY() - y;
                Rectangle2D reac = new Rectangle2D.Double(x, y, w, h);
                g.fill(reac);
            }
        }
        if (getShowNodes() && ((renderHints & Plot2D.RENDERHINT_DRAWPOINT) == Plot2D.RENDERHINT_DRAWPOINT)) {
            // nodes[index].setPoints(mapPoints(plotData));
            Ellipse2D.Double circle = new Ellipse2D.Double();
            int diameter = 2;
            if (renderHints == Plot2D.RENDERHINT_DRAWPOINT) {
                // only draw points, make them larger
                diameter = 4;
            }
            for (int i = 0; i < plotData.getSize(); i++) {
                circle.setFrameFromCenter(nodes[index].getPoints()[i].getX(), nodes[index].getPoints()[i].getY(), nodes[index].getPoints()[i].getX() + diameter, nodes[index].getPoints()[i].getY() + diameter);
                if (circle.intersects(plotRectHolder)) {
                    g.setColor(Color.gray);
                    g.fill(circle);
                }
            }
        }
    }
}
Also used : Point2D(java.awt.geom.Point2D) Rectangle(java.awt.Rectangle) Rectangle2D(java.awt.geom.Rectangle2D) Point(java.awt.Point) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D)

Example 85 with Point2D

use of java.awt.geom.Point2D in project vcell by virtualcell.

the class Plot2DPanel method getLinePlotSegments.

/**
 * Insert the method's description here.
 * Creation date: (2/7/2001 2:22:29 AM)
 * @param plotData cbit.plot.PlotData
 * @param index int
 * @return java.awt.geom.Line2D[]
 */
private Line2D[] getLinePlotSegments(PlotData plotData, int index) {
    // index means which plot(for a spacific variable), The array 'nodes' stores all the plots. comment added 4th Oct, 2006
    if (plotData != null && plotData.getSize() > 0) {
        nodes[index].setPoints(mapPoints(plotData));
        if (!getBStepMode()) {
            Line2D[] segments = new Line2D[plotData.getSize() - 1];
            for (int i = 0; i < plotData.getSize() - 1; i++) {
                segments[i] = new Line2D.Double(nodes[index].getPoints()[i], nodes[index].getPoints()[i + 1]);
            }
            return segments;
        } else {
            Line2D[] segments = new Line2D[(plotData.getSize() - 1) * 2];
            for (int i = 0; i < plotData.getSize() - 1; i++) {
                Point2D transientNode = new Point2D.Double(nodes[index].getPoints()[i + 1].getX(), nodes[index].getPoints()[i].getY());
                segments[2 * i] = new Line2D.Double(nodes[index].getPoints()[i], transientNode);
                segments[2 * i + 1] = new Line2D.Double(transientNode, nodes[index].getPoints()[i + 1]);
            }
            return segments;
        }
    } else {
        return null;
    }
}
Also used : Point2D(java.awt.geom.Point2D) Line2D(java.awt.geom.Line2D) Point(java.awt.Point) Paint(java.awt.Paint)

Aggregations

Point2D (java.awt.geom.Point2D)193 Color (java.awt.Color)22 Rectangle2D (java.awt.geom.Rectangle2D)20 RadialGradientPaint (java.awt.RadialGradientPaint)19 Graphics2D (java.awt.Graphics2D)18 Point (java.awt.Point)18 Paint (java.awt.Paint)17 Line2D (java.awt.geom.Line2D)12 AffineTransform (java.awt.geom.AffineTransform)11 Rectangle (java.awt.Rectangle)9 BasicStroke (java.awt.BasicStroke)8 Stroke (java.awt.Stroke)8 Ellipse2D (java.awt.geom.Ellipse2D)8 BufferedImage (java.awt.image.BufferedImage)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 Element (org.jdom2.Element)6 GradientPaint (java.awt.GradientPaint)5 Arc2D (java.awt.geom.Arc2D)5 GeneralPath (java.awt.geom.GeneralPath)5