Example usage for java.awt.geom Rectangle2D getWidth

List of usage examples for java.awt.geom Rectangle2D getWidth

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getWidth.

Prototype

public abstract double getWidth();

Source Link

Document

Returns the width of the framing rectangle in double precision.

Usage

From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java

public boolean renderVsParameter(Graphics2D g2, Rectangle2D dataArea) {

    final int imageWidth = (int) dataArea.getWidth();

    g2.setPaint(Color.red);// w w w .j  a  v a2s.  c  om

    final double parStep;
    parStep = Math.abs(upper - lower) / imageWidth;

    CoreStatusEvent statusEv = new CoreStatusEvent(this);

    //int ratio = upper / 100;

    int prevX[] = new int[model.getNVar()];
    int prevY[] = new int[model.getNVar()];

    for (double i = lower; i < upper; i += parStep) {
        double[] result;
        int transX, transY;

        parameters.put(firstParLabel, i);

        try {
            result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations);
        } catch (ModelException e) {
            String mess = "Exception while:\n" + dumpVariableDoubles(parameters)
                    + dumpVariableDoubles(initialPoint);
            throw new ModelException(mess, e);
        }

        for (int j = 0; j < result.length; j++) {

            transX = (int) this.domainAxis.valueToJava2D(i, dataArea, RectangleEdge.BOTTOM);

            transY = (int) this.rangeAxis.valueToJava2D(result[j], dataArea, RectangleEdge.LEFT);

            //                System.out.println("ly[" + j + "] = " + result[j]);
            //                System.out.println("x: " + transX + " y: " + transY);

            g2.setPaint(paintSequence[j]);
            //g2.fillRect(transX, transY, 1, 1);
            if (bigDots) {
                g2.fillRect(transX - 1, transY - 1, 3, 3);

            } else {
                g2.fillRect(transX, transY, 1, 1);
            }

            if (connectWithLines) {
                if (i != lower) {
                    g2.drawLine(transX, transY, prevX[j], prevY[j]);
                }

                prevX[j] = transX;
                prevY[j] = transY;
            }
        }

        if (stopped == true) {
            return false;
        }
        //else if (ratio > 0 && i % ratio == 0) {
        statusEv.setPercent(0);
        statusEv.setType(CoreStatusEvent.COUNT | CoreStatusEvent.PERCENT);
        notifyCoreStatusListeners(statusEv);
        //}

    }

    return true;
}

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

private double retrieveXx(CategoryItemRendererState state, Rectangle2D dataArea, int row, double categoryWidth,
        double xx, int seriesCount, int categoryCount) {
    double newXx = xx;
    if (seriesCount > 1) {
        double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1));
        double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1));
        // offset the start of the boxes if the total width used is smaller
        // than the category width
        double offset = (categoryWidth - usedWidth) / 2;
        newXx = xx + offset + (row * (state.getBarWidth() + seriesGap));
    } else {//w w  w.ja  va 2  s .  co  m
        double offset = (categoryWidth - state.getBarWidth()) / 2;
        newXx = xx + offset;
    }
    return newXx;
}

From source file:de.dakror.villagedefense.game.entity.struct.Struct.java

public void setBump(Rectangle2D r) {
    super.setBump(new Rectangle((int) Math.round(r.getX() * Tile.SIZE), (int) Math.round(r.getY() * Tile.SIZE),
            (int) Math.round(r.getWidth() * Tile.SIZE), (int) Math.round(r.getHeight() * Tile.SIZE)));
}

From source file:pku.sei.checkedcoverage.jung.ShowJungGraph.java

public void displayGraph(DirectedGraph<VertexType, SliceEdge<VertexType>> graph) {
    JFrame mainFrame = new JFrame("slice graph display");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Layout<VertexType, SliceEdge<VertexType>> layout = new KKLayout<VertexType, SliceEdge<VertexType>>(graph);
    final VisualizationViewer<VertexType, SliceEdge<VertexType>> viewer = new VisualizationViewer<VertexType, SliceEdge<VertexType>>(
            layout);// w  ww  . java 2  s . co m

    viewer.getRenderContext().setVertexLabelTransformer(this.vertexLabelTransformer);
    viewer.setVertexToolTipTransformer(this.vertexTooltipTransformer);
    viewer.getRenderContext().setEdgeLabelTransformer(new Transformer<SliceEdge<VertexType>, String>() {
        public String transform(SliceEdge<VertexType> edge) {
            Variable var = edge.getVariable();
            if (var instanceof ArrayElement) {
                ArrayElement elem = (ArrayElement) var;
                return "arr" + elem.getArrayId() + "[" + elem.getArrayIndex() + "]";
            } else if (var instanceof LocalVariable) {
                LocalVariable localVar = (LocalVariable) var;
                if (localVar.getVarName() != null)
                    return localVar.getVarName();
                return "local" + localVar.getVarIndex();
            } else if (var instanceof StackEntry) {
                return "stack";
            } else if (var instanceof ObjectField) {
                ObjectField objField = (ObjectField) var;
                return "obj" + objField.getObjectId() + "." + objField.getFieldName();
            } else if (var instanceof StaticField) {
                StaticField objField = (StaticField) var;
                String ownerInternalClassName = objField.getOwnerInternalClassName();
                String simpleClassName = getSimpleClassName(ownerInternalClassName);
                return simpleClassName + "." + objField.getFieldName();
            } else {
                assert var == null;
                return "";
            }
        }
    });
    viewer.setEdgeToolTipTransformer(new Transformer<SliceEdge<VertexType>, String>() {
        public String transform(SliceEdge<VertexType> edge) {
            Variable var = edge.getVariable();
            if (var instanceof ArrayElement) {
                ArrayElement elem = (ArrayElement) var;
                return "Array element " + elem.getArrayIndex() + " of array #" + elem.getArrayId();
            } else if (var instanceof LocalVariable) {
                LocalVariable localVar = (LocalVariable) var;
                if (localVar.getVarName() != null)
                    return "Local variable \"" + localVar.getVarName() + "\"";
                return "Local variable #" + localVar.getVarIndex();
            } else if (var instanceof StackEntry) {
                return "Dependency over the operand stack";
            } else if (var instanceof ObjectField) {
                ObjectField objField = (ObjectField) var;
                return "Field \"" + objField.getFieldName() + "\" of object #" + objField.getObjectId();
            } else if (var instanceof StaticField) {
                StaticField objField = (StaticField) var;
                String ownerInternalClassName = objField.getOwnerInternalClassName();
                return "Static field \"" + objField.getFieldName() + "\" of class \""
                        + Type.getType(ownerInternalClassName).getClassName();
            } else {
                assert var == null;
                return "Control dependency";
            }
        }
    });
    viewer.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<SliceEdge<VertexType>, Paint>() {
        public Paint transform(SliceEdge<VertexType> edge) {
            return edge.getVariable() == null ? Color.red : Color.black;
        }
    });

    viewer.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    viewer.getRenderContext().setVertexShapeTransformer(new Transformer<VertexType, Shape>() {
        public Shape transform(VertexType inst) {
            Font font = viewer.getFont();
            String text = viewer.getRenderContext().getVertexLabelTransformer().transform(inst);
            FontRenderContext fontRenderContext = ((Graphics2D) viewer.getGraphics()).getFontRenderContext();
            Rectangle2D bounds = font.getStringBounds(text, fontRenderContext);
            return new RoundRectangle2D.Double(-.6 * bounds.getWidth(), -.6 * bounds.getHeight(),
                    1.2 * bounds.getWidth(), 1.2 * bounds.getHeight(), 8, 8);
        }
    });

    viewer.setBackground(Color.white);

    DefaultModalGraphMouse<InstructionInstance, SliceEdge<VertexType>> mouse = new DefaultModalGraphMouse<InstructionInstance, SliceEdge<VertexType>>();
    mouse.setMode(Mode.ANNOTATING);
    viewer.setGraphMouse(mouse);

    mainFrame.getContentPane().add(viewer);
    mainFrame.pack();

    mainFrame.setVisible(true);
}

From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphNode.java

/**
 * Draw a GraphNode as a rectangle with a name
 *
 * @param g   The Java2D Graphics/*from  ww w .  j  a  v  a  2 s  .  co m*/
 * @param col The color to draw
 */
public void drawNode(final Graphics2D g, final Color col) {
    final int x = displayPosition.x;
    final int y = displayPosition.y;

    g.setFont(g.getFont().deriveFont(Font.BOLD, 11));
    final FontMetrics metrics = g.getFontMetrics();
    final String name = node.getId();
    final Rectangle2D rect = metrics.getStringBounds(name, g);
    final int stringWidth = (int) rect.getWidth();
    setSize(Math.max(stringWidth, 50) + 10, 25);

    int step = 4;
    int alpha = 96;
    for (int i = 0; i < step; ++i) {
        g.setColor(new Color(0, 0, 0, alpha - (32 * i)));
        g.drawLine(x + i + 1, y + nodeHeight + i, x + nodeWidth + i - 1, y + nodeHeight + i);
        g.drawLine(x + nodeWidth + i, y + i, x + nodeWidth + i, y + nodeHeight + i);
    }

    Shape clipShape = new Rectangle(x, y, nodeWidth, nodeHeight);

    g.setComposite(AlphaComposite.SrcAtop);
    g.setPaint(new GradientPaint(x, y, col, x + nodeWidth, y + nodeHeight, col.darker()));
    g.fill(clipShape);

    g.setColor(Color.blue);
    g.draw3DRect(x, y, nodeWidth - 1, nodeHeight - 1, true);

    g.setColor(Color.BLACK);
    g.drawString(name, x + (nodeWidth - stringWidth) / 2, y + 15);
}

From source file:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java

/**
 * Creates the listener responsible for calling the correct handlers based
 * on mouse events, and to select invidual cells.
 *//*from   w w  w  . jav  a 2 s.c om*/
protected MouseListener createMouseListener() {

    return new MouseHandler() {

        /**
         * Invoked when a mouse button has been pressed on a component.
         *
         //@Override
         public void mousePressed(MouseEvent e) {
                
         Object o = graph.getFirstCellForLocation(e.getX(), e.getY());
                
         if (o instanceof VGraphCell) {
                
         VGraphCell cell = (VGraphCell) o;
                
         JPopupMenu menu = new JPopupMenu();
                
         VChartPanel chartPanel = (VChartPanel) cell.getUserObject();
                
         if (chartPanel.isShowPopUp()) {
                
         LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems();
         JMenu first = new JMenu("1-39");
         int checker = 0;
                
         for (Iterator iter = collect.iterator(); iter.hasNext();) {
         LegendItem item = (LegendItem) iter.next();
         checker++;
         first.add(new JMenuItem(item.getLabel()));
         if ((checker % 40) == 0) {
         menu.add(first);
                
         first = new JMenu("" + checker + "-" + (checker + 39));
         }
         if (!iter.hasNext()) {
         menu.add(first);
         }
         }
                
         menu.show(graph, e.getX(), e.getY());
         }
         }
                
         super.mousePressed(e);
         }
         */

        /**
         * Invoked when a mouse button has been pressed on a component.
         */
        @Override
        public void mousePressed(MouseEvent e) {

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (SwingUtilities.isLeftMouseButton(e) && e.isAltDown()) {
                if (o instanceof VGraphCell) {

                    VGraphCell cell = (VGraphCell) o;

                    JPopupMenu menu = new JPopupMenu();

                    VChartPanel chartPanel = (VChartPanel) cell.getUserObject();

                    LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems();
                    JMenu first = new JMenu("1-39");
                    int checker = 0;

                    for (Iterator iter = collect.iterator(); iter.hasNext();) {
                        LegendItem item = (LegendItem) iter.next();
                        checker++;
                        first.add(new JMenuItem(item.getLabel()));
                        if ((checker % 40) == 0) {
                            menu.add(first);

                            first = new JMenu("" + checker + "-" + (checker + 39));
                        }
                        if (!iter.hasNext()) {
                            menu.add(first);
                        }
                    }

                    menu.show(graph, e.getX(), e.getY());
                }
            }

            super.mousePressed(e);

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    for (MouseListener l : chart.getMouseListeners()) {
                        l.mousePressed(e);
                    }
                }
            }
        }

        // Event may be null when called to cancel the current operation.
        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    for (MouseListener l : chart.getMouseListeners()) {
                        l.mouseReleased(e);
                    }
                }
            }
        }

        /**
         * Invoked when the mouse has been clicked on a component.
         */
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                VGraphCell cell = (VGraphCell) o;

                o = cell.getUserObject();

                if (o != null && o instanceof VChartPanel) {
                    VChartPanel chart = (VChartPanel) o;

                    if (SwingUtilities.isRightMouseButton(e)) {
                        JPopupMenu menu = chart.createPopupMenu(true, true, true, true);

                        menu.show(graph, e.getX(), e.getY());
                    }

                    /*
                    for (MouseListener l : chart.getMouseListeners()) {
                    System.out.println("LISTENS CLI");
                    l.mouseClicked(e);
                    }
                    */
                }
            }
        }

        /*
        // Event may be null when called to cancel the current operation.
        @Override
        public void mouseReleased(MouseEvent e) {
        super.mouseReleased(e);
                
        Object[] cells = graphSelectionModel.getSelectionCells();
                
        Rectangle2D bounds = graph.getCellBounds(cells);
                
        if (bounds != null) {
            Rectangle2D b2 = graph.toScreen((Rectangle2D) bounds.clone());
            graph.scrollRectToVisible(new Rectangle((int) b2.getX(), (int) b2.getY(), (int) b2.getWidth(), (int) b2.getHeight()));
        }
        }
        */

        /**
         * Invoked when the mouse pointer has been moved on a component (with no
         * buttons down).
         */
        @Override
        public void mouseMoved(MouseEvent e) {

            if (graph.isMoveable()) {
                super.mouseMoved(e);
            }

            Object o = graph.getFirstCellForLocation(e.getX(), e.getY());

            if (o != null && o instanceof VGraphCell) {

                selectedCell = (VGraphCell) o;

                Rectangle2D bounds = graph.getCellBounds(selectedCell);

                menu.show(graph, (int) (bounds.getX() + bounds.getWidth()),
                        (int) bounds.getY() + (int) (bounds.getHeight() - menu.getHeight()));
            }
        }
    };
}

From source file:de.unisb.cs.st.javaslicer.jung.ShowJungGraph.java

public void displayGraph(DirectedGraph<VertexType, SliceEdge<VertexType>> graph) {
    JFrame mainFrame = new JFrame("slice graph display");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Layout<VertexType, SliceEdge<VertexType>> layout = new KKLayout<VertexType, SliceEdge<VertexType>>(graph);
    final VisualizationViewer<VertexType, SliceEdge<VertexType>> viewer = new VisualizationViewer<VertexType, SliceEdge<VertexType>>(
            layout);//from w ww. ja v  a2  s .c  o  m

    viewer.getRenderContext().setVertexLabelTransformer(this.vertexLabelTransformer);
    viewer.setVertexToolTipTransformer(this.vertexTooltipTransformer);
    viewer.getRenderContext().setEdgeLabelTransformer(new Transformer<SliceEdge<VertexType>, String>() {
        @Override
        public String transform(SliceEdge<VertexType> edge) {
            Variable var = edge.getVariable();
            if (var instanceof ArrayElement) {
                ArrayElement elem = (ArrayElement) var;
                return "arr" + elem.getArrayId() + "[" + elem.getArrayIndex() + "]";
            } else if (var instanceof LocalVariable) {
                LocalVariable localVar = (LocalVariable) var;
                if (localVar.getVarName() != null)
                    return localVar.getVarName();
                return "local" + localVar.getVarIndex();
            } else if (var instanceof StackEntry) {
                return "stack";
            } else if (var instanceof ObjectField) {
                ObjectField objField = (ObjectField) var;
                return "obj" + objField.getObjectId() + "." + objField.getFieldName();
            } else if (var instanceof StaticField) {
                StaticField objField = (StaticField) var;
                String ownerInternalClassName = objField.getOwnerInternalClassName();
                String simpleClassName = getSimpleClassName(ownerInternalClassName);
                return simpleClassName + "." + objField.getFieldName();
            } else {
                assert var == null;
                return "";
            }
        }
    });
    viewer.setEdgeToolTipTransformer(new Transformer<SliceEdge<VertexType>, String>() {
        @Override
        public String transform(SliceEdge<VertexType> edge) {
            Variable var = edge.getVariable();
            if (var instanceof ArrayElement) {
                ArrayElement elem = (ArrayElement) var;
                return "Array element " + elem.getArrayIndex() + " of array #" + elem.getArrayId();
            } else if (var instanceof LocalVariable) {
                LocalVariable localVar = (LocalVariable) var;
                if (localVar.getVarName() != null)
                    return "Local variable \"" + localVar.getVarName() + "\"";
                return "Local variable #" + localVar.getVarIndex();
            } else if (var instanceof StackEntry) {
                return "Dependency over the operand stack";
            } else if (var instanceof ObjectField) {
                ObjectField objField = (ObjectField) var;
                return "Field \"" + objField.getFieldName() + "\" of object #" + objField.getObjectId();
            } else if (var instanceof StaticField) {
                StaticField objField = (StaticField) var;
                String ownerInternalClassName = objField.getOwnerInternalClassName();
                return "Static field \"" + objField.getFieldName() + "\" of class \""
                        + Type.getType(ownerInternalClassName).getClassName();
            } else {
                assert var == null;
                return "Control dependency";
            }
        }
    });
    viewer.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<SliceEdge<VertexType>, Paint>() {
        @Override
        public Paint transform(SliceEdge<VertexType> edge) {
            return edge.getVariable() == null ? Color.red : Color.black;
        }
    });

    viewer.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    viewer.getRenderContext().setVertexShapeTransformer(new Transformer<VertexType, Shape>() {
        @Override
        public Shape transform(VertexType inst) {
            Font font = viewer.getFont();
            String text = viewer.getRenderContext().getVertexLabelTransformer().transform(inst);
            FontRenderContext fontRenderContext = ((Graphics2D) viewer.getGraphics()).getFontRenderContext();
            Rectangle2D bounds = font.getStringBounds(text, fontRenderContext);
            return new RoundRectangle2D.Double(-.6 * bounds.getWidth(), -.6 * bounds.getHeight(),
                    1.2 * bounds.getWidth(), 1.2 * bounds.getHeight(), 8, 8);
        }
    });

    viewer.setBackground(Color.white);

    DefaultModalGraphMouse<InstructionInstance, SliceEdge<VertexType>> mouse = new DefaultModalGraphMouse<InstructionInstance, SliceEdge<VertexType>>();
    mouse.setMode(Mode.ANNOTATING);
    viewer.setGraphMouse(mouse);

    mainFrame.getContentPane().add(viewer);
    mainFrame.pack();

    mainFrame.setVisible(true);
}

From source file:figs.treeVisualization.gui.TimeAxisTree2DPanel.java

/**
 * Estimate the maximum date width, this also tacks on the tick mark outside length.
 *
 * @param g2/*from   w  w  w.  ja  v a 2 s.  c  o m*/
 */
private void estimateMaximumDateWidth(Graphics2D g2) {
    double maxWidth = 0.0;
    RectangleInsets insets = this.fDateAxis.getLabelInsets();
    FontMetrics fm = g2.getFontMetrics(this.fDateAxis.getTickLabelFont());
    DateFormat formatter = this.fDateAxis.getDateFormatOverride();

    for (Iterator<Calendar> i = this.fLeafDates.values().iterator(); i.hasNext();) {
        Date tickDate = i.next().getTime();
        String tickLabel;
        if (formatter != null) {
            tickLabel = formatter.format(tickDate);
        } else {
            tickLabel = this.fDateAxis.getTickUnit().dateToString(tickDate);
        }
        Rectangle2D labelBounds = TextUtilities.getTextBounds(tickLabel, g2, fm);
        if (labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth) {
            maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight();
        }
    }

    this.fEstMaxDateWidth = maxWidth + this.fDateAxis.getTickMarkOutsideLength();
}

From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java

/**
 * Returns the frame surrounding the specified view rectangle.
 * /*from   w  w w.ja  v  a2  s  . c om*/
 * @param view  the view rectangle (<code>null</code> not permitted).
 */
private Rectangle2D viewToFrame(Rectangle2D view) {
    double width = view.getWidth() / this.viewW;
    double height = view.getHeight() / this.viewH;
    double x = view.getX() - (width * this.viewX);
    double y = view.getY() - (height * this.viewY);
    return new Rectangle2D.Double(x, y, width, height);
}

From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java

private XYAnnotation slopeLine() {
    return new XYAnnotation() {

        private double x1, y1, x2, y2;

        @Override/*from w w  w .  j a va  2s.  com*/
        public void removeChangeListener(final AnnotationChangeListener listener) {
            // ignore
        }

        @Override
        public void addChangeListener(final AnnotationChangeListener listener) {
            // ignore
        }

        @Override
        public void draw(final Graphics2D g2, final XYPlot plot, final Rectangle2D dataArea,
                final ValueAxis domainAxis, final ValueAxis rangeAxis, final int rendererIndex,
                final PlotRenderingInfo info) {
            calcLineCoords(dataArea);
            drawLine(g2);
        }

        private void drawLine(final Graphics2D g2) {
            final Color origColor = g2.getColor();
            g2.setColor(Color.black);
            g2.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            g2.setColor(Color.lightGray);
            g2.drawLine((int) x1, 0, (int) x1, 192);
            g2.drawLine((int) x2, 0, (int) x2, 192);
            g2.setColor(origColor);
        }

        @SuppressWarnings("synthetic-access")
        private void calcLineCoords(final Rectangle2D rect) {
            // offset necessary since chart is not drawn on whole rectangle
            int offset = 12;
            final double x = rect.getMinX() + offset;
            final double y = rect.getMinY();
            final double w = rect.getWidth() - 2 * offset;
            final double h = rect.getHeight();
            final double min = bundle.getTheoreticalMin();
            final double max = bundle.getTheoreticalMax();
            final double defaultMin = bundle.getDataMin();
            final double defaultMax = bundle.getDataMax();
            final double scale = w / (defaultMax - defaultMin);
            double slope = 0.0;
            if (max != min) {
                slope = h / (max - min);
            }
            if (min >= defaultMin) {
                x1 = scale * (min - defaultMin);
                y1 = h;
            } else {
                x1 = 0;
                if (max > min) {
                    y1 = h - ((defaultMin - min) * slope);
                } else {
                    y1 = h;
                }
            }
            if (max <= defaultMax) {
                x2 = (scale * (max - defaultMin));
                y2 = 0;
            } else {
                x2 = w;
                if (max > min) {
                    y2 = h - ((defaultMax - min) * slope);
                } else {
                    y2 = 0;
                }
            }
            x1 += x;
            x2 += x;
            y1 += y;
            y2 += y;
        }
    };
}