public void paint(Graphics2D g2) {

        //update the shape in java Path2D object if it changed
        if (hasChanged) {
            x_points = new int[points.size()];
            y_points = new int[points.size()];
            for (int i=0; i < points.size(); i++) {
                x_points[i] = (int)points.get(i).x;
                y_points[i] = (int)points.get(i).y;
            }
            hasChanged = false;
        }
        //don't draw if path2D is empty (not shape)
        if (x_points != null) {
        	
        	// special draw for selection
        	if (isSelected) {
        		g2.setColor(Color.YELLOW);
        		g2.setStroke(new BasicStroke(strokeThickness * 4));
            	if (isClosed)
                    g2.drawPolygon(x_points, y_points, points.size());
                else
                    g2.drawPolyline(x_points, y_points, points.size());
        	}
        	
        	g2.setColor(colour);

            // call right drawing function
            if (isFilled) {
                g2.fillPolygon(x_points, y_points, points.size());
            }
            else {
            	g2.setStroke(new BasicStroke(strokeThickness)); 
            	if (isClosed)
                    g2.drawPolygon(x_points, y_points, points.size());
                else
                    g2.drawPolyline(x_points, y_points, points.size());
            }
        }
    }