Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke() 

Source Link

Document

Constructs a new BasicStroke with defaults for all attributes.

Usage

From source file:it.iit.genomics.cru.igb.bundles.mi.view.TestJung.java

public static void main(String[] args) {

    Graph<MoleculeEntry, EdgeInteraction> graph = new SparseMultigraph<>();

    MoleculeEntry v1 = new MoleculeEntry("A");
    v1.addGeneName("A");
    v1.setTaxid("9606");

    MoleculeEntry v2 = new MoleculeEntry("B");
    v2.addGeneName("b");
    v2.setTaxid("9606");

    MoleculeEntry v3 = new MoleculeEntry("DNA");
    v3.addGeneName("DNA");
    v3.setTaxid(MoleculeEntry.TAXID_DNA);

    EdgeInteraction edge = new EdgeInteraction(true, true, true, "e1");
    graph.addEdge(edge, v1, v2, EdgeType.UNDIRECTED);

    EdgeInteraction edge2 = new EdgeInteraction(false, false, true, "e2");
    graph.addEdge(edge2, v1, v3, EdgeType.UNDIRECTED);

    EdgeInteraction edge3 = new EdgeInteraction(false, false, false, "e3");
    graph.addEdge(edge3, v2, v3, EdgeType.UNDIRECTED);

    // The Layout<V, E> is parameterized by the vertex and edge types
    Layout<MoleculeEntry, EdgeInteraction> layout = new ISOMLayout(graph);

    layout.setSize(new Dimension(500, 600)); // sets the initial size of the space
    // The BasicVisualizationServer<V,E> is parameterized by the edge types
    VisualizationViewer<MoleculeEntry, EdgeInteraction> vv = new VisualizationViewer<>(layout);

    vv.setPreferredSize(new Dimension(550, 650)); //Sets the viewing area size
    vv.setBackground(Color.WHITE);
    Transformer<MoleculeEntry, Paint> vertexPaint = new Transformer<MoleculeEntry, Paint>() {
        @Override//  w  w  w . ja  v  a2s .  c o m
        public Paint transform(MoleculeEntry molecule) {
            switch (molecule.getTaxid()) {
            case MoleculeEntry.TAXID_DNA:
                ;
            case MoleculeEntry.TAXID_RNA:
                return Color.GREEN;
            case MoleculeEntry.TAXID_LIGAND:
                return Color.MAGENTA;
            default:
                return Color.GREEN;
            }
        }
    };

    Transformer<EdgeInteraction, Paint> edgePaint = new Transformer<EdgeInteraction, Paint>() {
        @Override
        public Paint transform(EdgeInteraction interaction) {
            return interaction.hasStructure ? Color.BLACK : Color.GRAY;
        }
    };

    final Stroke edgeStroke01 = new BasicStroke();

    final float nodeSize = 20;

    final Stroke edgeStrokeBothContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) },
            nodeSize, true, true);

    final Stroke edgeStrokeStartContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) },
            nodeSize, true, false);

    final Stroke edgeStrokeEndContacts = new ShapeStroke(new Shape[] { new Ellipse2D.Float(0, 0, 10, 10) },
            nodeSize, false, true);

    final Stroke edgeStrokeBothContact = new CompoundStroke(edgeStroke01, edgeStrokeBothContacts,
            CompoundStroke.ADD);

    final Stroke edgeStrokeStartContact = new CompoundStroke(edgeStroke01, edgeStrokeStartContacts,
            CompoundStroke.ADD);

    final Stroke edgeStrokeEndContact = new CompoundStroke(edgeStroke01, edgeStrokeEndContacts,
            CompoundStroke.ADD);

    Transformer<EdgeInteraction, Stroke> edgeStrokeTransformer = new Transformer<EdgeInteraction, Stroke>() {
        @Override
        public Stroke transform(EdgeInteraction s) {
            if (s.hasContactsA && s.hasContactsB) {
                return edgeStrokeBothContact;
            }

            if (s.hasContactsA) {
                return edgeStrokeStartContact;
            }

            if (s.hasContactsB) {
                return edgeStrokeEndContact;
            }

            return edgeStroke01;
        }
    };

    Transformer<MoleculeEntry, String> moleculeLabeller = new Transformer<MoleculeEntry, String>() {
        @Override
        public String transform(MoleculeEntry s) {
            return s.getGeneName();
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);

    vv.getRenderContext().setVertexLabelTransformer(moleculeLabeller);

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

    vv.setGraphMouse(graphMouse);

    JFrame frame = new JFrame("Network " + "A");

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().add(vv);
    frame.pack();

    frame.setVisible(true);
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setPaint(Color.black);/*from w w  w.  j a  va  2  s  . c o  m*/
    g2.setStroke(new BasicStroke());
    g2.draw(new Ellipse2D.Double(20, 20, 50, 50));
}

From source file:gda.plots.SimpleLegendItem.java

/**
 * Creates a LegendItem by extracting the necessary information from the supplied SimpleXYSeries.
 * //from   w w  w .  j av  a  2s.c  om
 * @param sxys
 *            the SimpleXYSeries
 */
public SimpleLegendItem(SimpleXYSeries sxys) {
    super(sxys.getName(), sxys.getName(), null, null, sxys.isDrawMarkers(), sxys.getSymbol(), sxys.getFilled(),
            sxys.getSymbolPaint(), !sxys.getFilled(), sxys.getSymbolPaint(), new BasicStroke(),
            sxys.isDrawLines(), new Line2D.Double(-8.0, 0.0, 8.0, 0.0), sxys.getStroke(), sxys.getPaint());
    this.sxys = sxys;
}

From source file:gda.plots.SimpleXYBarRenderer.java

/**
 * Creates a SimpleLegendItem for a SimpleXYSeries in the dataset.
 * //from w ww  .  j ava 2  s . c  o m
 * @param datasetIndex
 *            which dataset (left or right effectively)
 * @param series
 *            which data series
 * @return the created legend
 */
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
    LegendItem result = null;

    XYPlot plot = getPlot();
    if (plot != null) {
        SimpleXYSeriesCollection dataset = (SimpleXYSeriesCollection) plot.getDataset(datasetIndex);
        if (dataset != null) {
            SimpleXYSeries sxys = (SimpleXYSeries) dataset.getSeries(series);
            if (sxys.isVisible() && sxys.isVisibleInLegend()) {
                result = new LegendItem(sxys.getName(), sxys.getName(), null, null, sxys.isDrawMarkers(),
                        sxys.getSymbol(), sxys.getFilled(), sxys.getSymbolPaint(), !sxys.getFilled(),
                        sxys.getSymbolPaint(), new BasicStroke(), sxys.isDrawLines(),
                        new Line2D.Double(-8.0, 0.0, 8.0, 0.0), sxys.getStroke(), sxys.getPaint());
            }
        }
    }
    return result;

}

From source file:edu.jhuapl.graphs.jfreechart.JFreeChartLineGraphSource.java

@Override
public JFreeChart createChart(String title, String xLabel, String yLabel, CategoryDataset dataset,
        boolean legend, boolean graphToolTip) {
    PlotOrientation orientation = getParam(PLOT_ORIENTATION, PlotOrientation.class, DEFAULT_PLOT_ORIENTATION);

    JFreeChart result = ChartFactory.createLineChart(title, xLabel, yLabel, dataset, orientation, legend,
            graphToolTip, false);//from w  ww .  ja  va  2s  . c o  m

    CategoryLineGraphRenderer r = new CategoryLineGraphRenderer(data);

    Shape graphShape = getParam(GraphSource.GRAPH_SHAPE, Shape.class, DEFAULT_GRAPH_SHAPE);
    Paint graphColor = getParam(GraphSource.GRAPH_COLOR, Paint.class, DEFAULT_GRAPH_COLOR);
    Stroke graphStroke = getParam(GraphSource.GRAPH_STROKE, Stroke.class, new BasicStroke());

    setupRenderer(r, graphColor, graphShape, graphStroke);
    result.getCategoryPlot().setRenderer(r);

    return result;
}

From source file:TextLayoutWithCarets.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

    if (mInitialized == false)
        initialize(g2);//from w  w w  .  j av  a  2  s  .c o  m

    float x = 20, y = 80;
    mLayout.draw(g2, x, y);

    // Create a plain stroke and a dashed stroke.
    Stroke[] caretStrokes = new Stroke[2];
    caretStrokes[0] = new BasicStroke();
    caretStrokes[1] = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0, new float[] { 4, 4 },
            0);

    // Now draw the carets
    Shape[] carets = mLayout.getCaretShapes(mHit.getInsertionIndex());
    for (int i = 0; i < carets.length; i++) {
        if (carets[i] != null) {
            AffineTransform at = AffineTransform.getTranslateInstance(x, y);
            Shape shape = at.createTransformedShape(carets[i]);
            g2.setStroke(caretStrokes[i]);
            g2.draw(shape);
        }
    }
}

From source file:no.met.jtimeseries.chart.XYCloudSymbolRenderer.java

/**
 * Draws the visual representation of a single symbol.
 *//*from  w  w w . j a  v  a  2  s.  c om*/
@Override
public void drawItem(Graphics2D g2d, XYItemRendererState state, Rectangle2D plotArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {
    // Needs a new graphics object to use translate() and rotate()
    Graphics2D g2 = (Graphics2D) g2d.create();
    g2.setRenderingHints(renderHints);

    double middleY = plotArea.getCenterY();
    CloudDataset cloudData = (CloudDataset) dataset;
    Number x = cloudData.getX(series, item);
    double middleX = domainAxis.valueToJava2D(x.doubleValue(), plotArea, plot.getDomainAxisEdge());
    g2.translate((int) middleX, (int) middleY); // make x=0, y=0 the middle of the symbol
    g2.setStroke(new BasicStroke());
    double height = plotArea.getHeight() - 2;

    // we set the width to be 20 which is the same as the weather symbols 
    double width = calculateWidth(plotArea.getWidth());
    double startX = -(width / 2);
    double startY[] = { -(height / 2), -(height / 4), 0, (height / 4) };
    double values[] = { (cloudData.getHighClouds(series, item).doubleValue() / 100.0),
            (cloudData.getMediumClouds(series, item).doubleValue() / 100.0),
            (cloudData.getLowClouds(series, item).doubleValue() / 100.0),
            (cloudData.getFog(series, item).doubleValue() / 100.0) };

    for (int i = 0; i < values.length; i++) { // for each cloud type
        g2.setColor(new Color(96, 96, 96));
        g2.fill(new Rectangle2D.Double(startX, startY[i], (width * values[i]), (height / 4 - 1))); // plot could
        g2.setColor(new Color(97, 204, 247));
        g2.fill(new Rectangle2D.Double(startX + (width * values[i]), startY[i], (width * (1 - values[i])),
                (height / 4 - 1))); // plot sky
    }
}

From source file:demo.EdgeLabelDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the label positioning features/*from ww w.ja  v  a 2  s. c  o  m*/
 * 
 */
@SuppressWarnings("serial")
public EdgeLabelDemo() {

    // create a simple graph for the demo
    graph = new SparseMultigraph<Integer, Number>();
    Integer[] v = createVertices(3);
    createEdges(v);

    Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph);
    vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400));
    vv.setBackground(Color.white);

    vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer();
    edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer();

    Transformer<Number, String> stringer = new Transformer<Number, String>() {
        public String transform(Number e) {
            return "Edge:" + graph.getEndpoints(e).toString();
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(stringer);

    float dash[] = { 10.0f };
    final Stroke edgeStroke2 = new BasicStroke();
    final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
            0.0f);
    Transformer<Number, Stroke> edgeStrokeTransformer = new Transformer<Number, Stroke>() {
        public Stroke transform(Number s) {
            return edgeStroke;
        }
    };
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);

    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>());
    //vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));
    //vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));

    // add my listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>());

    // create a frome to hold the graph
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    Container content = getContentPane();
    content.add(panel);
    /*
      final DefaultModalGraphMouse<Integer,Number> graphMouse = new DefaultModalGraphMouse<Integer,Number>();
      vv.setGraphMouse(graphMouse);
            
      JButton plus = new JButton("+");
      plus.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        scaler.scale(vv, 1.1f, vv.getCenter());
    }
      });
      JButton minus = new JButton("-");
      minus.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        scaler.scale(vv, 1/1.1f, vv.getCenter());
    }
      });
            
      ButtonGroup radio = new ButtonGroup();
      JRadioButton lineButton = new JRadioButton("Line");
      lineButton.addItemListener(new ItemListener(){
    public void itemStateChanged(ItemEvent e) {
        if(e.getStateChange() == ItemEvent.SELECTED) {
            vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer,Number>());
            vv.repaint();
        }
    }
      });
            
      JRadioButton quadButton = new JRadioButton("QuadCurve");
      quadButton.addItemListener(new ItemListener(){
    public void itemStateChanged(ItemEvent e) {
        if(e.getStateChange() == ItemEvent.SELECTED) {
            vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer,Number>());
            vv.repaint();
        }
    }
      });
            
      JRadioButton cubicButton = new JRadioButton("CubicCurve");
      cubicButton.addItemListener(new ItemListener(){
    public void itemStateChanged(ItemEvent e) {
        if(e.getStateChange() == ItemEvent.SELECTED) {
            vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer,Number>());
            vv.repaint();
        }
    }
      });
      radio.add(lineButton);
      radio.add(quadButton);
      radio.add(cubicButton);
            
      graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
            
      JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>");
      rotate.addItemListener(new ItemListener(){
    public void itemStateChanged(ItemEvent e) {
        AbstractButton b = (AbstractButton)e.getSource();
        edgeLabelRenderer.setRotateEdgeLabels(b.isSelected());
        vv.repaint();
    }
      });
      rotate.setSelected(true);
      MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7);
      vv.getRenderContext().setEdgeLabelClosenessTransformer(mv);
      JSlider directedSlider = new JSlider(mv.getDirectedModel()) {
    public Dimension getPreferredSize() {
        Dimension d = super.getPreferredSize();
        d.width /= 2;
        return d;
    }
      };
      JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) {
    public Dimension getPreferredSize() {
        Dimension d = super.getPreferredSize();
        d.width /= 2;
        return d;
    }
      };
            
      JSlider edgeOffsetSlider = new JSlider(0,50) {
    public Dimension getPreferredSize() {
        Dimension d = super.getPreferredSize();
        d.width /= 2;
        return d;
    }
      };
      edgeOffsetSlider.addChangeListener(new ChangeListener() {
            
    public void stateChanged(ChangeEvent e) {
        JSlider s = (JSlider)e.getSource();
        AbstractEdgeShapeTransformer<Integer,Number> aesf = 
            (AbstractEdgeShapeTransformer<Integer,Number>)vv.getRenderContext().getEdgeShapeTransformer();
        aesf.setControlOffsetIncrement(s.getValue());
        vv.repaint();
    }
            
      });
            
      Box controls = Box.createHorizontalBox();
            
      JPanel zoomPanel = new JPanel(new GridLayout(0,1));
      zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale"));
      zoomPanel.add(plus);
      zoomPanel.add(minus);
            
      JPanel edgePanel = new JPanel(new GridLayout(0,1));
      edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type"));
      edgePanel.add(lineButton);
      edgePanel.add(quadButton);
      edgePanel.add(cubicButton);
            
      JPanel rotatePanel = new JPanel();
      rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment"));
      rotatePanel.add(rotate);
            
      JPanel labelPanel = new JPanel(new BorderLayout());
      JPanel sliderPanel = new JPanel(new GridLayout(3,1));
      JPanel sliderLabelPanel = new JPanel(new GridLayout(3,1));
      JPanel offsetPanel = new JPanel(new BorderLayout());
      offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset"));
      sliderPanel.add(directedSlider);
      sliderPanel.add(undirectedSlider);
      sliderPanel.add(edgeOffsetSlider);
      sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT));
      sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT));
      sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT));
      offsetPanel.add(sliderLabelPanel, BorderLayout.WEST);
      offsetPanel.add(sliderPanel);
      labelPanel.add(offsetPanel);
      labelPanel.add(rotatePanel, BorderLayout.WEST);
            
      JPanel modePanel = new JPanel(new GridLayout(2,1));
      modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
      modePanel.add(graphMouse.getModeComboBox());
            
      controls.add(zoomPanel);
      controls.add(edgePanel);
      controls.add(labelPanel);
      controls.add(modePanel);
      content.add(controls, BorderLayout.SOUTH);
      quadButton.setSelected(true);
     */
}

From source file:com.compomics.pepshell.view.statistics.RatioStatisticsScatterplotPane.java

@Override
public void setGraphData(PepshellProtein aPepshellProtein) {
    List<XYLineAnnotation> annotations = new ArrayList<>();
    XYSeriesCollection allExperiments = new XYSeriesCollection();
    for (Experiment anExperiment : experiments) {
        int proteinIndex = anExperiment.getProteins().indexOf(aPepshellProtein);
        if (proteinIndex != -1) {
            XYSeries anExperimentSeries = new XYSeries(anExperiment.getExperimentName());
            PepshellProtein experimentPepshellProtein = anExperiment.getProteins().get(proteinIndex);
            for (PeptideGroup aGroup : experimentPepshellProtein.getPeptideGroups()) {
                PeptideInterface shortestPeptide = aGroup.getRepresentativePeptide();

                if (shortestPeptide instanceof QuantedPeptide
                        && ((QuantedPeptide) shortestPeptide).getRatio() != null) {
                    Double value = Math.log(((QuantedPeptide) shortestPeptide).getRatio()) / Math.log(2);
                    //Double value = ((QuantedPeptide) shortestPeptide).getRatio();                          
                    if (value == Double.NEGATIVE_INFINITY) {
                        value = 0.0;//from www  .  j  a v  a 2s  .  c  o m
                    }
                    double barWithErrors = (shortestPeptide.getEndProteinMatch()
                            + shortestPeptide.getBeginningProteinMatch()) / 2;
                    double error = Math.log(((QuantedPeptide) shortestPeptide).getStandardError())
                            / Math.log(2);
                    //double error =((QuantedPeptide) shortestPeptide).getStandardError();
                    XYLineAnnotation vertical = new XYLineAnnotation(barWithErrors, value - error,
                            barWithErrors, value + error, new BasicStroke(), Color.black);
                    XYLineAnnotation horizontalUpper = new XYLineAnnotation(value + error - 0.25, value + error,
                            value + error + 0.25, value + error, new BasicStroke(), Color.black);
                    XYLineAnnotation horizontalLower = new XYLineAnnotation(value - error - 0.25, value - error,
                            value - error + 0.25, value - error, new BasicStroke(), Color.black);

                    annotations.add(vertical);
                    annotations.add(horizontalUpper);
                    annotations.add(horizontalLower);

                    for (int i = shortestPeptide.getBeginningProteinMatch(); i < shortestPeptide
                            .getEndProteinMatch(); i++) {
                        anExperimentSeries.add(i, value);
                    }
                }

            }
            allExperiments.addSeries(anExperimentSeries);

        }
    }
    JFreeChart ratioChart = ChartFactory.createHistogram(
            "ratio for " + aPepshellProtein.getVisibleAccession() + " over all experiments", "peptide start",
            "log^2 ratio", allExperiments, PlotOrientation.VERTICAL, true, true, false);
    chart.setChart(ratioChart);
    for (XYLineAnnotation anAnnotation : annotations) {
        ((XYPlot) ratioChart.getPlot()).addAnnotation(anAnnotation);
    }
    prettifyChart(ratioChart);
}

From source file:ucar.unidata.idv.control.chart.TrackSegment.java

/**
 * Draws the wayPoint.//from w  ww. java 2 s.  com
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  an optional info object that will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis,
        int rendererIndex, PlotRenderingInfo info) {
    super.setGraphicsState(g2);

    if (!getPlotWrapper().okToDraw(this)) {
        return;
    }
    WayPoint leftWayPoint = getLeft();
    WayPoint rightWayPoint = getRight();
    g2.setStroke(new BasicStroke());
    int x1 = leftWayPoint.getXFromValue(dataArea, domainAxis);
    int x2 = rightWayPoint.getXFromValue(dataArea, domainAxis);
    int top = (int) (dataArea.getY());
    int bottom = (int) (dataArea.getY() + dataArea.getHeight());
    FontMetrics fm = g2.getFontMetrics();
    int width = fm.stringWidth(getName());
    int height = fm.getAscent() + fm.getDescent();
    if (getSelected()) {
        g2.setColor(Color.red);
    } else {
        g2.setColor(Color.black);
    }
    //      int y = bottom-3;
    y = top - 2;
    int textLeft = x1 + (x2 - x1) / 2 - width / 2;
    g2.drawString(getName(), textLeft, y);
    g2.setStroke(new BasicStroke(2.0f));
    g2.drawLine(x1, top + 1, x2, top + 1);
    g2.setStroke(new BasicStroke(1.0f));
    g2.setColor(Color.gray);
    g2.drawLine(x1, top, x1, bottom - WayPoint.ANNOTATION_WIDTH);
    g2.drawLine(x2, top, x2, bottom - WayPoint.ANNOTATION_WIDTH);
}