@Override
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        grid.paint(g,0);
        Graphics2D g2 = (Graphics2D) g;
        //Rectangle2D bounds = getBounds();
        Rectangle2D graphBounds = PSTricksGraphEditor.graph.getBounds(g2);
        graphSize = new double[4];
        graphSize[0] = graphBounds.getMaxX();
        graphSize[1] = graphBounds.getMaxY();
        graphSize[2] = graphBounds.getMinX();
        graphSize[3] = graphBounds.getMinY();
        
        PSTricksGraphEditor.graph.draw(g2);
        
        if (selected instanceof Node){
            Rectangle2D selecterBounds = ((Node) selected).getBounds();
            drawSelector(g2, selecterBounds.getMinX(), selecterBounds.getMinY());
            drawSelector(g2, selecterBounds.getMinX(), selecterBounds.getMaxY());
            drawSelector(g2, selecterBounds.getMaxX(), selecterBounds.getMinY());
            drawSelector(g2, selecterBounds.getMaxX(), selecterBounds.getMaxY());
        }
        
        if (selected instanceof PSTLabel){
            Rectangle2D selecterBounds = ((PSTLabel) selected).getBounds();
            drawSelector(g2, selecterBounds.getMinX(), selecterBounds.getMinY());
            drawSelector(g2, selecterBounds.getMinX(), selecterBounds.getMaxY());
            drawSelector(g2, selecterBounds.getMaxX(), selecterBounds.getMinY());
            drawSelector(g2, selecterBounds.getMaxX(), selecterBounds.getMaxY());
        }
        
        if (selected instanceof Edge){
            if(selected instanceof LineEdge){
                Line2D line = new Line2D.Double(
                        ((LineEdge) selected).getConnectionPoints()[0],
                        ((LineEdge) selected).getConnectionPoints()[1]);
            
                drawSelector(g2, line.getX1(), line.getY1());
                drawSelector(g2, line.getX2(), line.getY2());
            }
            
            if(selected instanceof ArcEdge){
                drawSelector(g2, ((ArcEdge) selected).getConnectionPoints()[0].getX(), ((Edge) selected).getConnectionPoints()[0].getY());
                drawSelector(g2, ((ArcEdge) selected).getConnectionPoints()[1].getX(), ((Edge) selected).getConnectionPoints()[1].getY());
                drawSelector(g2, ((ArcEdge) selected).getCtrlPoint().getX(), ((ArcEdge) selected).getCtrlPoint().getY());
            }
            
            if(selected instanceof CircleEdge){
                drawSelector(g2, ((CircleEdge) selected).getConnectionPoints()[0].getX(),((CircleEdge) selected).getConnectionPoints()[0].getY());
                drawSelector(g2, ((CircleEdge) selected).getConnectionPoints()[1].getX(),((CircleEdge) selected).getConnectionPoints()[1].getY());
            }
        }
        
        if (selecterBandStart != null){
            Color oldColour = g2.getColor();
            g2.setColor(selectorColour);
            g2.setStroke(new BasicStroke(1,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
            g2.draw(new Line2D.Double(selecterBandStart, lastMousePoint));
            g2.setColor(oldColour);
        }
    }