Example usage for javax.swing Icon Icon

List of usage examples for javax.swing Icon Icon

Introduction

In this page you can find the example usage for javax.swing Icon Icon.

Prototype

Icon

Source Link

Usage

From source file:com.google.code.facebook.graph.sna.applet.DrawnIconVertexDemo.java

public DrawnIconVertexDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseGraph<Integer, Number>();
    Integer[] v = createVertices(10);
    createEdges(v);/*from www .j a va2  s. c  om*/

    vv = new VisualizationViewer<Integer, Number>(new FRLayout<Integer, Number>(graph));
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<Integer, String>() {

        public String transform(Integer v) {
            return "Vertex " + v;
        }
    });
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    vv.getRenderContext().setVertexIconTransformer(new Transformer<Integer, Icon>() {

        /*
         * Implements the Icon interface to draw an Icon with background color and
         * a text label
         */
        public Icon transform(final Integer v) {
            return new Icon() {

                public int getIconHeight() {
                    return 20;
                }

                public int getIconWidth() {
                    return 20;
                }

                public void paintIcon(Component c, Graphics g, int x, int y) {
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.yellow);
                    } else {
                        g.setColor(Color.red);
                    }
                    g.fillOval(x, y, 20, 20);
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.white);
                    }
                    g.drawString("" + v, x + 6, y + 15);

                }
            };
        }
    });

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.white, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.lightGray));

    vv.setBackground(Color.white);

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

    // create a frome to hold the graph
    final JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(gm);

    final ScalingControl scaler = new CrossoverScalingControl();

    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());
        }
    });

    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    content.add(controls, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(true);
}

From source file:edu.uci.ics.jung.samples.DrawnIconVertexDemo.java

@SuppressWarnings("unchecked")
public DrawnIconVertexDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseGraph<Integer, Number>();
    Integer[] v = createVertices(10);
    createEdges(v);//from  w w w  .ja  va2  s. c o  m

    vv = new VisualizationViewer<Integer, Number>(new FRLayout<Integer, Number>(graph));
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<Integer, String>() {

        public String transform(Integer v) {
            return "Vertex " + v;
        }
    });
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    vv.getRenderContext().setVertexIconTransformer(new Transformer<Integer, Icon>() {

        /*
         * Implements the Icon interface to draw an Icon with background color and
         * a text label
         */
        public Icon transform(final Integer v) {
            return new Icon() {

                public int getIconHeight() {
                    return 20;
                }

                public int getIconWidth() {
                    return 20;
                }

                public void paintIcon(Component c, Graphics g, int x, int y) {
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.yellow);
                    } else {
                        g.setColor(Color.red);
                    }
                    g.fillOval(x, y, 20, 20);
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.white);
                    }
                    g.drawString("" + v, x + 6, y + 15);

                }
            };
        }
    });

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.white, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.lightGray));

    vv.setBackground(Color.white);

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

    // create a frome to hold the graph
    final JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(gm);

    final ScalingControl scaler = new CrossoverScalingControl();

    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());
        }
    });

    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    content.add(controls, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(true);
}

From source file:de.unidue.inf.is.ezdl.gframedl.tools.relations.DLObjectGraphView.java

private void setRenderers() {
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<DLObject, String>() {

        @Override/*  w w  w  .  j a v a  2s. c o m*/
        public String transform(DLObject v) {
            String result = "";
            if (v instanceof Person) {
                result = ((Person) v).getFirstName() + " " + ((Person) v).getLastName();
            }
            if (v instanceof TextDocument) {
                result = ((TextDocument) v).getTitle();
            }
            return result;
        }
    });
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.red));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
    vv.getRenderContext().setVertexShapeTransformer(new VertexShapeFunction<DLObject>());

    vv.getRenderContext().setVertexIconTransformer(new Transformer<DLObject, Icon>() {

        @Override
        public Icon transform(final DLObject v) {
            final int size = getVertexSize(v);
            return new Icon() {

                @Override
                public int getIconHeight() {
                    return size;
                }

                @Override
                public int getIconWidth() {
                    return size;
                }

                @Override
                public void paintIcon(Component c, Graphics g, int x, int y) {
                    int halfSize = size / 2;
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.yellow);
                    } else {
                        g.setColor(Color.lightGray);
                    }
                    g.fillOval(x, y, size, size);

                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.red);
                    } else {
                        g.setColor(Color.black);
                    }
                    g.drawOval(x, y, size, size);

                    int iconX = x + halfSize - 8;
                    int iconY = y + halfSize - 8;

                    if (v instanceof Person) {
                        Icons.MEDIA_AUTHOR.get16x16().paintIcon(c, g, iconX, iconY);
                    }
                    if (v instanceof TextDocument) {
                        Icons.MEDIA_TEXT.get16x16().paintIcon(c, g, iconX, iconY);
                    }
                    if (v instanceof Term) {
                        Icons.MEDIA_TERM.get16x16().paintIcon(c, g, iconX, iconY);
                    }
                }
            };
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.black));
    vv.setBackground(Color.white);
}

From source file:edu.ku.brc.services.mapping.LocalityMapper.java

/**
 * Grabs a new map from the web service and appropriately adorns it
 * with labels and markers./* w  w  w.ja v a  2 s  .  co m*/
 *
 * @return a map image as an icon
 * @throws HttpException a network error occurred while grabbing the map from the service
 * @throws IOException a network error occurred while grabbing the map from the service
 */
protected Icon grabNewMap() throws HttpException, IOException {
    recalculateBoundingBox();

    if (!cacheValid) {
        //            Image mapImage = getMapFromService("mapus.jpl.nasa.gov",
        //                    "/wms.cgi?request=GetMap&srs=EPSG:4326&format=image/png&styles=visual",
        //                    "global_mosaic",
        //                    mapMinLat, mapMinLong, mapMaxLat, mapMaxLong, maxMapHeight, maxMapWidth);
        //
        //            Image overlayImage = getMapFromService("129.237.201.132",
        //                    "/cgi-bin/mapserv?map=/var/www/maps/specify.map&service=WMS&request=GetMap&srs=EPSG:4326&version=1.3.1&format=image/png&transparent=true",
        //                    "states,rivers",
        //                    mapMinLat, mapMinLong, mapMaxLat, mapMaxLong, maxMapHeight, maxMapWidth);

        Image mapImage = getMapFromService("lifemapper.org", //$NON-NLS-1$
                "/ogc?map=specify.map&service=WMS&request=GetMap&srs=EPSG:4326&version=1.3.1&STYLES=&format=image/png&transparent=TRUE", //$NON-NLS-1$
                "global_mosaic,states,rivers", //$NON-NLS-1$
                mapMinLat, mapMinLong, mapMaxLat, mapMaxLong, maxMapHeight, maxMapWidth);

        mapIcon = new ImageIcon(mapImage);
        //            overlayIcon = new ImageIcon(overlayImage);
        cacheValid = true;

        mapWidth = mapIcon.getIconWidth();
        mapHeight = mapIcon.getIconHeight();

        if (mapWidth < 0 || mapHeight < 0) {
            throw new IOException("Request for map failed.  Received map has negative width or height."); //$NON-NLS-1$
        }

        mapLatRange = mapMaxLat - mapMinLat;
        mapLongRange = mapMaxLong - mapMinLong;

        pixelPerLatRatio = mapHeight / mapLatRange;
        pixelPerLongRatio = mapWidth / mapLongRange;

        for (int i = 0; i < mapLocations.size(); ++i) {
            MapLocationIFace loc = mapLocations.get(i);
            Point iconLoc = determinePixelCoordsOfMapLocationIFace(loc);
            markerLocations.set(i, iconLoc);
        }

        cacheValid = true;
    }

    Icon icon = new Icon() {
        public void paintIcon(Component c, Graphics g, int x, int y) {
            // this helps keep the labels inside the map
            g.setClip(x, y, mapWidth, mapHeight);
            // log the x and y for the MouseMotionListener
            mostRecentPaintedX = x;
            mostRecentPaintedY = y;
            Point currentLocPoint = null;
            if (currentLoc != null) {
                currentLocPoint = determinePixelCoordsOfMapLocationIFace(currentLoc);
            }

            mapIcon.paintIcon(c, g, x, y);
            //                overlayIcon.paintIcon(c, g, x, y);

            Point lastLoc = null;
            for (int i = 0; i < mapLocations.size(); ++i) {
                Point markerLoc = markerLocations.get(i);
                String label = labels.get(i);
                boolean current = (currentLoc != null) && markerLoc.equals(currentLocPoint);

                if (markerLoc == null) {
                    log.error("A marker location is null"); //$NON-NLS-1$
                    continue;
                }
                if (!pointIsOnMapIcon(x + markerLoc.x, y + markerLoc.y)) {
                    log.error("A marker location is off the map"); //$NON-NLS-1$
                    continue;
                }
                if (showArrows && lastLoc != null) {
                    int x1 = x + lastLoc.x;
                    int y1 = y + lastLoc.y;
                    int x2 = x + markerLoc.x;
                    int y2 = y + markerLoc.y;
                    Color origColor = g.getColor();
                    if (current && !animationInProgress) {
                        g.setColor(getCurrentLocColor());
                    } else {
                        g.setColor(arrowColor);
                    }
                    GraphicsUtils.drawArrow(g, x1, y1, x2, y2, 2, 2);
                    g.setColor(origColor);
                }
                if (current) {
                    currentLocMarker.paintIcon(c, g, markerLoc.x + x, markerLoc.y + y);
                } else {
                    marker.paintIcon(c, g, markerLoc.x + x, markerLoc.y + y);
                }
                if (label != null) {
                    Color origColor = g.getColor();
                    FontMetrics fm = g.getFontMetrics();
                    int length = fm.stringWidth(label);
                    g.setColor(Color.WHITE);
                    g.fillRect(markerLoc.x + x - (length / 2), markerLoc.y + y - (fm.getHeight() / 2), length,
                            fm.getHeight());
                    g.setColor(labelColor);
                    GraphicsUtils.drawCenteredString(label, g, markerLoc.x + x, markerLoc.y + y);
                    g.setColor(origColor);
                }

                lastLoc = markerLoc;
            }
            if (showArrowAnimations && animationInProgress) {
                int startIndex = mapLocations.indexOf(animStartLoc);
                int endIndex = mapLocations.indexOf(animEndLoc);
                if (startIndex != -1 && endIndex != -1) {
                    Point startPoint = markerLocations.get(startIndex);
                    Point endPoint = markerLocations.get(endIndex);
                    Point arrowEnd = GraphicsUtils.getPointAlongLine(startPoint, endPoint, percent);
                    Color orig = g.getColor();
                    g.setColor(getCurrentLocColor());
                    GraphicsUtils.drawArrow(g, startPoint.x + x, startPoint.y + y, arrowEnd.x + x,
                            arrowEnd.y + y, 5, 3);
                    g.setColor(orig);
                }
            }
        }

        public int getIconWidth() {
            return mapWidth;
        }

        public int getIconHeight() {
            return mapHeight;
        }
    };

    return icon;
}

From source file:org.cloudml.ui.graph.Visu.java

public void createFrame() {
    final VisualizationViewer<Vertex, Edge> vv = v.getVisualisationViewer();

    vv.getRenderContext().setVertexIconTransformer(new Transformer<Vertex, Icon>() {
        public Icon transform(final Vertex v) {
            return new Icon() {

                public int getIconHeight() {
                    return 40;
                }/*www.jav  a 2 s.com*/

                public int getIconWidth() {
                    return 40;
                }

                public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
                    ImageIcon img;
                    if (v.getType() == "node") {
                        img = new ImageIcon(this.getClass().getResource("/server.png"));
                    } else if (v.getType() == "platform") {
                        img = new ImageIcon(this.getClass().getResource("/dbms.png"));
                    } else {
                        img = new ImageIcon(this.getClass().getResource("/soft.png"));
                    }
                    ImageObserver io = new ImageObserver() {

                        public boolean imageUpdate(Image img, int infoflags, int x, int y, int width,
                                int height) {
                            // TODO Auto-generated method stub
                            return false;
                        }
                    };
                    g.drawImage(img.getImage(), x, y, getIconHeight(), getIconWidth(), io);

                    if (!vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.red);

                        properties.setModel(new CPIMTable(v));
                        runtimeProperties.setModel(new CPSMTable(v));
                    }
                    g.drawString(v.getName(), x - 10, y + 50);
                }
            };
        }
    });

    // create a frame to hold the graph
    final JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(gm);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton save = new JButton("save");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "save");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            OutputStream streamResult;
            try {
                streamResult = new FileOutputStream(result);
                codec.save(dmodel, streamResult);
            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    JButton saveImage = new JButton("save as image");
    saveImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "save");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            v.writeJPEGImage(result);
        }
    });
    //WE NEED TO UPDATE THE FACADE AND THE GUI
    JButton load = new JButton("load");
    load.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showDialog(frame, "load");
            File result = fc.getSelectedFile();
            JsonCodec codec = new JsonCodec();
            try {
                InputStream stream = new FileInputStream(result);
                Deployment model = (Deployment) codec.load(stream);
                dmodel = model;
                v.setDeploymentModel(dmodel);
                ArrayList<Vertex> V = v.drawFromDeploymentModel();
                nodeTypes.removeAll();
                nodeTypes.setModel(fillList());

                properties.setModel(new CPIMTable(V.get(0)));
                runtimeProperties.setModel(new CPSMTable(V.get(0)));

                CommandFactory fcommand = new CommandFactory();
                CloudMlCommand load = fcommand.loadDeployment(result.getPath());
                cml.fireAndWait(load);

            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton deploy = new JButton("Deploy!");
    deploy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //cad.deploy(dmodel);
            System.out.println("deploy");
            CommandFactory fcommand = new CommandFactory();
            CloudMlCommand deploy = fcommand.deploy();
            cml.fireAndWait(deploy);
        }
    });

    //right panel
    JPanel intermediary = new JPanel();
    intermediary.setLayout(new BoxLayout(intermediary, BoxLayout.PAGE_AXIS));
    intermediary.setBorder(BorderFactory.createLineBorder(Color.black));

    JLabel jlCPIM = new JLabel();
    jlCPIM.setText("CPIM");

    JLabel jlCPSM = new JLabel();
    jlCPSM.setText("CPSM");

    properties = new JTable(null);
    //properties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    JTableHeader h = properties.getTableHeader();
    JPanel props = new JPanel();
    props.setLayout(new BorderLayout());
    props.add(new JScrollPane(properties), BorderLayout.CENTER);
    props.add(h, BorderLayout.NORTH);

    runtimeProperties = new JTable(null);
    //runtimeProperties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    JTableHeader h2 = runtimeProperties.getTableHeader();
    JPanel runProps = new JPanel();
    runProps.setLayout(new BorderLayout());
    runProps.add(h2, BorderLayout.NORTH);
    runProps.add(new JScrollPane(runtimeProperties), BorderLayout.CENTER);

    intermediary.add(jlCPIM);
    intermediary.add(props);
    intermediary.add(jlCPSM);
    intermediary.add(runProps);

    content.add(intermediary, BorderLayout.EAST);

    //Left panel
    JPanel selection = new JPanel();
    JLabel nodes = new JLabel();
    nodes.setText("Types");
    selection.setLayout(new BoxLayout(selection, BoxLayout.PAGE_AXIS));
    nodeTypes = new JList(fillList());
    nodeTypes.setLayoutOrientation(JList.VERTICAL);
    nodeTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    nodeTypes.setVisibleRowCount(10);
    JScrollPane types = new JScrollPane(nodeTypes);
    types.setPreferredSize(new Dimension(150, 80));
    selection.add(nodes);
    selection.add(types);

    content.add(selection, BorderLayout.WEST);

    ((DefaultModalGraphMouse<Integer, Number>) gm)
            .add(new MyEditingGraphMousePlugin(0, vv, v.getGraph(), nodeTypes, dmodel));
    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    controls.add(save);
    controls.add(saveImage);
    controls.add(load);
    controls.add(deploy);
    controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox());
    content.add(controls, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(true);
}

From source file:org.ujmp.jung.VertexIconTransformer.java

public Icon transform(final N v) {
    return new Icon() {

        public int getIconHeight() {
            return 10;
        }/* w w w  .  java 2 s.co  m*/

        public int getIconWidth() {
            return 10;
        }

        public void paintIcon(Component c, Graphics g, int x, int y) {
            Graphics2D g2d = (Graphics2D) g;
            if (pickedVertexState.isPicked(v)) {
                g2d.setColor(UIDefaults.SELECTEDCOLOR);
            } else {
                g2d.setColor(ColorUtil.fromObject(v));
            }
            g2d.fillOval(x, y, 10, 10);
            g2d.setColor(new Color(150, 150, 150, 150));
            g2d.drawOval(x, y, 10, 10);
        }
    };
}

From source file:thesaurusEditor.gui.graph.MainGraph.java

/**
 * create an instance of a simple graph with basic controls
 *///  ww w . ja  v a2s .  com
public MainGraph(List<Konzept> konzepte, Main main) {

    // create a simple graph for the demo
    this.konzepte = konzepte;
    this.main = main;

    main.getController().getThesaurus().addObserver(this);

    graph = new DirectedSparseGraph<Konzept, EdgeClass>();

    for (Konzept k : konzepte) {
        graph.addVertex(k);
    }
    createEdges(konzepte);

    layout = new PersistentLayoutImpl<Konzept, EdgeClass>(new FRLayout<Konzept, EdgeClass>(graph));
    //layout = new FRLayout<Konzept,EdgeClass>(graph);
    Dimension preferredSize = new Dimension(1300, 900);
    final VisualizationModel<Konzept, EdgeClass> visualizationModel = new DefaultVisualizationModel<Konzept, EdgeClass>(
            layout, preferredSize);
    vv = new VisualizationViewer<Konzept, EdgeClass>(visualizationModel, preferredSize);

    // this class will provide both label drawing and vertex shapes
    VertexLabelAsShapeRenderer<Konzept, EdgeClass> vlasr = new VertexLabelAsShapeRenderer<Konzept, EdgeClass>(
            vv.getRenderContext());

    // customize the render context
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<Konzept, String>() {
        public String transform(Konzept k) {
            return "";
        }
    });
    // this chains together Transformers so that the html tags
    // are prepended to the toString method output
    /*new ChainedTransformer<Konzept,String>(new Transformer[]{
    new ToStringLabeller<Konzept>(),
    new Transformer<Konzept,String>() {
     public String transform(Konzept input) {
        return input.toString();
     }}}));*/
    vv.getRenderContext().setVertexShapeTransformer(new Transformer<Konzept, Shape>() {
        public Shape transform(Konzept k) {
            return new Rectangle(-((k.toString().length() * 8 + 10) / 2), -(10), k.toString().length() * 7 + 18,
                    21);
        }
    });
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.red));
    vv.getRenderContext().setEdgeDrawPaintTransformer(new ConstantTransformer(Color.black));
    vv.getRenderContext().setEdgeStrokeTransformer(new ConstantTransformer(new BasicStroke(2.5f)));

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Konzept>(vv.getPickedVertexState(), Color.white, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<EdgeClass>(vv.getPickedEdgeState(), Color.black, Color.red));

    vv.getRenderContext().setVertexIconTransformer(new Transformer<Konzept, Icon>() {

        /*
         * Implements the Icon interface to draw an Icon with background color and
         * a text label
         */
        public Icon transform(final Konzept v) {
            return new Icon() {
                private Konzept k;

                public int getIconHeight() {
                    return 20;
                }

                public int getIconWidth() {
                    if (k != null) {
                        return k.toString().length() * 7 + 10;
                    }
                    return v.toString().length() * 7 + 10;
                }

                public void paintIcon(Component c, Graphics g, int x, int y) {
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.yellow);
                    } else {
                        g.setColor(Color.lightGray);
                    }
                    g.fillRect(x, y, v.toString().length() * 8 + 10, 20);

                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.black);
                    }
                    g.drawRect(x, y, v.toString().length() * 8 + 10, 20);
                    if (vv.getPickedVertexState().isPicked(v)) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.black);
                    }
                    this.k = v;

                    if (vv.getPickedVertexState().isPicked(v)) {
                        Font font = new Font("DejaVu Sans Mono", Font.BOLD, 14);
                        g.setFont(font);
                        g.drawString("" + v, x + 6, y + 15);
                    } else {
                        Font font = new Font("DejaVu Sans Mono", Font.PLAIN, 14);
                        g.setFont(font);
                        g.drawString("" + v, x + 6, y + 15);
                    }
                    this.k = v;

                }
            };
        }
    });

    // customize the renderer
    /*GradientVertexRenderer<Konzept,EdgeClass> vertex = new GradientVertexRenderer<Konzept,EdgeClass>(Color.white, Color.white, true);
    vv.getRenderer().setVertexRenderer(vertex);
    vv.getRenderer().setVertexLabelRenderer(vlasr); */

    vv.setBackground(Color.white);

    // add a listener for ToolTips
    KonzeptParser<Konzept> parser = new KonzeptParser<Konzept>();
    vv.setVertexToolTipTransformer(parser);

    /*final DefaultModalGraphMouse<Konzept,Edge> graphMouse = 
    new DefaultModalGraphMouse<Konzept,Edge>();
    */

    Factory<Konzept> vertexFactory = new VertexFactory();
    Factory<EdgeClass> edgeFactory = new EdgeFactory();

    graphMouse = new MyModalGraphMouse<Konzept, EdgeClass>(vv.getRenderContext(), vertexFactory, edgeFactory,
            main, vv);

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    // the EditingGraphMouse will pass mouse event coordinates to the
    // vertexLocations function to set the locations of the vertices as
    // they are created
    //        graphMouse.setVertexLocations(vertexLocations);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING);

    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    //graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton();
    plus.setIcon(new ImageIcon(getClass().getResource("/thesaurusEditor/img/zoom_in.png")));
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton();
    minus.setIcon(new ImageIcon(getClass().getResource("/thesaurusEditor/img/zoom_out.png")));
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel controls = new JPanel();
    JPanel zoomControls = new JPanel(new GridLayout(1, 2));
    //zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    zoomControls.add(plus);
    zoomControls.add(minus);
    controls.add(zoomControls);
    //controls.add(modeBox);
    /*
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(gzsp);
    gzsp.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 374, Short.MAX_VALUE)
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 106, Short.MAX_VALUE)
    );
            
            
    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(controls);
    controls.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 374, Short.MAX_VALUE)
    );
    jPanel2Layout.setVerticalGroup(
    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 164, Short.MAX_VALUE)
    );*/

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(gzsp, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(controls, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap()
                    .addComponent(gzsp, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(controls, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

}