Example usage for javax.swing JPanel setSize

List of usage examples for javax.swing JPanel setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:com.project.traceability.GUI.ProjectCreateWindow.java

public JPanel config(String configname) {

    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    pc.newProject();//  w  ww  .  j  a v  a 2  s  .c  om
    Workspace workspace = pc.getCurrentWorkspace();

    // Import file
    ImportController importController = Lookup.getDefault().lookup(ImportController.class);
    Container container = null;
    try {
        // File file = new File("PropertyFileToConfigurationFile.gexf");
        File file = new File(configname);
        container = importController.importFile(file);
    } catch (Exception ex) {
        ex.printStackTrace();

    }

    // Append imported data to GraphAPI
    importController.process(container, new DefaultProcessor(), workspace);

    // Preview configuration
    PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
    PreviewModel previewModel = previewController.getModel();

    previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.SHOW_EDGE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_COLOR,
            new DependantOriginalColor(Color.BLUE));
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_SHOW_BOX, Boolean.TRUE);
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_BOX_COLOR, new DependantColor(Color.YELLOW));

    previewModel.getProperties().putValue(PreviewProperty.EDGE_LABEL_COLOR,
            new DependantOriginalColor(Color.BLACK));
    previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_FONT,
            previewModel.getProperties().getFontValue(PreviewProperty.NODE_LABEL_FONT).deriveFont(20));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_THICKNESS, new Float(2f));
    // previewModel.getProperties().putValue(PreviewProperty.NODE_BORDER_COLOR,new DependantColor(DependantColor.Mode.PARENT));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_COLOR, new EdgeColor(Color.RED));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED, Boolean.FALSE);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 100);
    previewModel.getProperties().putValue(PreviewProperty.NODE_OPACITY, 200);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 0f);
    previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, Color.WHITE);
    previewController.refreshPreview();

    // New Processing target, get the PApplet
    ProcessingTarget target = (ProcessingTarget) previewController
            .getRenderTarget(RenderTarget.PROCESSING_TARGET);
    PApplet applet = target.getApplet();
    applet.init();

    // Refresh the preview and reset the zoom
    previewController.render(target);
    target.refresh();
    target.resetZoom();

    // Add the applet to a JFrame and display
    JPanel panel1 = new JPanel();
    panel1.setLayout(new BorderLayout());

    panel1.add(applet, BorderLayout.CENTER);
    // new JPanel().add(applet,BorderLayout.CENTER);
    panel1.setSize(1650, 1080);
    return panel1;
}

From source file:com.project.traceability.GUI.ProjectCreateWindow.java

public JPanel deploy(String deployname) {
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    pc.newProject();/*  w  w  w.j  ava2 s  .c o m*/
    Workspace workspace = pc.getCurrentWorkspace();

    // Import file
    ImportController importController = Lookup.getDefault().lookup(ImportController.class);
    Container container = null;
    try {
        // File file = new File("PropertyFileToConfigurationFile.gexf");
        File file = new File(deployname);
        container = importController.importFile(file);
    } catch (Exception ex) {
        ex.printStackTrace();

    }

    // Append imported data to GraphAPI
    importController.process(container, new DefaultProcessor(), workspace);

    // Preview configuration
    PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
    PreviewModel previewModel = previewController.getModel();

    previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.SHOW_EDGE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_COLOR,
            new DependantOriginalColor(Color.BLUE));
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_SHOW_BOX, Boolean.TRUE);
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_BOX_COLOR, new DependantColor(Color.YELLOW));

    previewModel.getProperties().putValue(PreviewProperty.EDGE_LABEL_COLOR,
            new DependantOriginalColor(Color.BLACK));
    previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_FONT,
            previewModel.getProperties().getFontValue(PreviewProperty.NODE_LABEL_FONT).deriveFont(20));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_THICKNESS, new Float(2f));
    // previewModel.getProperties().putValue(PreviewProperty.NODE_BORDER_COLOR,new DependantColor(DependantColor.Mode.PARENT));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_COLOR, new EdgeColor(Color.GREEN));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED, Boolean.FALSE);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 100);
    previewModel.getProperties().putValue(PreviewProperty.NODE_OPACITY, 200);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 0f);
    previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, Color.WHITE);
    previewController.refreshPreview();

    // New Processing target, get the PApplet
    ProcessingTarget target = (ProcessingTarget) previewController
            .getRenderTarget(RenderTarget.PROCESSING_TARGET);
    PApplet applet = target.getApplet();
    applet.init();

    // Refresh the preview and reset the zoom
    previewController.render(target);
    target.refresh();
    target.resetZoom();

    // Add the applet to a JFrame and display
    JPanel panel3 = new JPanel();
    panel3.setLayout(new BorderLayout());

    panel3.add(applet, BorderLayout.CENTER);
    // new JPanel().add(applet,BorderLayout.CENTER);
    panel3.setSize(1650, 1080);
    return panel3;

}

From source file:com.project.traceability.GUI.ProjectCreateWindow.java

public JPanel test(String testname) {
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    pc.newProject();/*from   www .ja v  a2  s. c om*/
    Workspace workspace = pc.getCurrentWorkspace();

    // Import file
    ImportController importController = Lookup.getDefault().lookup(ImportController.class);
    Container container = null;
    try {
        // File file = new File("PropertyFileToConfigurationFile.gexf");
        File file = new File(testname);
        container = importController.importFile(file);
    } catch (Exception ex) {
        ex.printStackTrace();

    }

    // Append imported data to GraphAPI
    importController.process(container, new DefaultProcessor(), workspace);

    // Preview configuration
    //      PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
    //      PreviewModel previewModel = previewController.getModel();
    //
    //      previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE); 
    //        previewModel.getProperties().putValue(PreviewProperty.SHOW_EDGE_LABELS, Boolean.TRUE); 
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_COLOR, new DependantOriginalColor(Color.RED));
    ////        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_SHOW_BOX, Boolean.TRUE);
    ////        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_BOX_COLOR, new DependantColor(Color.YELLOW));
    //        
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_LABEL_COLOR, new DependantOriginalColor(Color.BLACK));
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_FONT, previewModel.getProperties().getFontValue(PreviewProperty.NODE_LABEL_FONT).deriveFont(20));
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_THICKNESS, new Float(2f));
    //       // previewModel.getProperties().putValue(PreviewProperty.NODE_BORDER_COLOR,new DependantColor(DependantColor.Mode.PARENT));
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_COLOR,new EdgeColor(Color.BLUE));           
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED, Boolean.FALSE); 
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 100);
    //        previewModel.getProperties().putValue(PreviewProperty.NODE_OPACITY, 200);
    //        previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 0f); 
    //        previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, Color.WHITE); 
    //        previewController.refreshPreview(); 

    PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
    PreviewModel previewModel = previewController.getModel();

    previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.SHOW_EDGE_LABELS, Boolean.TRUE);
    previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_COLOR,
            new DependantOriginalColor(Color.RED));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_LABEL_COLOR,
            new DependantOriginalColor(Color.GREEN));
    // previewModel.getProperties().putValue(PreviewProperty.NODE_BORDER_COLOR,new DependantColor(DependantColor.Mode.PARENT));
    //previewModel.getProperties().putValue(PreviewProperty.EDGE_COLOR, new DependantOriginalColor(Color.GREEN));
    previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED, Boolean.FALSE);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 50);
    previewModel.getProperties().putValue(PreviewProperty.EDGE_RADIUS, 0f);
    previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, Color.WHITE);
    previewController.refreshPreview();

    // New Processing target, get the PApplet
    ProcessingTarget target = (ProcessingTarget) previewController
            .getRenderTarget(RenderTarget.PROCESSING_TARGET);
    PApplet applet = target.getApplet();
    applet.init();

    // Refresh the preview and reset the zoom
    previewController.render(target);
    target.refresh();
    target.resetZoom();

    // Add the applet to a JFrame and display
    JPanel panel2 = new JPanel();
    panel2.setLayout(new BorderLayout());

    panel2.add(applet, BorderLayout.CENTER);
    // new JPanel().add(applet,BorderLayout.CENTER);
    panel2.setSize(1650, 1080);
    return panel2;

}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//w  w  w.j  a  v a2 s . c o  m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:net.sf.jasperreports.swing.JRViewerPanel.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            AreaHyperlinksRenderable imageMap = null;
            if (element instanceof JRPrintImage) {
                Renderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof AreaHyperlinksRenderable) {
                    imageMap = (AreaHyperlinksRenderable) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//  w  ww.  j  a v  a2s.com
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:net.pms.newgui.SelectRenderers.java

public void build() {
    JPanel checkPanel = new JPanel();
    checkPanel.applyComponentOrientation(ComponentOrientation.getOrientation(PMS.getLocale()));
    add(checkPanel, BorderLayout.LINE_START);
    allRenderers = new SearchableMutableTreeNode(Messages.getString("GeneralTab.13"));

    Pattern pattern = Pattern.compile("^\\s*([^\\s]*) ?([^\\s].*?)?\\s*$");
    for (String renderer : RendererConfiguration.getAllRenderersNames()) {
        Matcher match = pattern.matcher(renderer);
        if (match.find()) {
            // Find or create group or single name renderer
            SearchableMutableTreeNode node = null;
            try {
                node = allRenderers.findChild(match.group(1));
            } catch (IllegalChildException e) {
            }/*w  w  w .j a va2s .  c  o  m*/
            if (node == null) {
                node = new SearchableMutableTreeNode(match.group(1));
                allRenderers.add(node);
            }
            // Find or create subgroup/name
            if (match.groupCount() > 1 && match.group(2) != null) {
                SearchableMutableTreeNode subNode = null;
                try {
                    subNode = node.findChild(match.group(2));
                } catch (IllegalChildException e) {
                }
                if (subNode != null) {
                    LOGGER.warn("Renderer {} found twice, ignoring repeated entry", renderer);
                } else {
                    subNode = new SearchableMutableTreeNode(match.group(2));
                    node.add(subNode);
                }
            }
        } else {
            LOGGER.warn("Can't parse renderer name \"{}\"", renderer);
        }
    }

    SrvTree = new JTree(new DefaultTreeModel(allRenderers));
    checkTreeManager = new CheckTreeManager(SrvTree);
    checkPanel.add(new JScrollPane(SrvTree));
    checkPanel.setSize(400, 500);
}

From source file:com.openbravo.pos.util.JRViewer411.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//ww w . jav  a 2  s .  c  o m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:neg.JRViewer.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//  w  w  w  .j a  v a  2 s  . c om
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            ImageMapRenderable imageMap = null;
            if (element instanceof JRPrintImage) {
                Renderable renderer = ((JRPrintImage) element).getRenderable();
                if (renderer instanceof ImageMapRenderable) {
                    imageMap = (ImageMapRenderable) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }/* w  ww .java2s  .co  m*/
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:motor.part.MainPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    Banner_Panel.setVisible(false);
    Customer_Panel.setVisible(false);
    Admin_Panel.setVisible(false);
    Deleted_Message.setVisible(false);//  w  w  w .  j  av  a2s  . c o m
    Details_Error_panel.setVisible(false);
    Graph_Panel.setVisible(true);
    DefaultCategoryDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset, "Last Month Sales");
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(1300, 600));
    // add it to our application
    chartPanel.setVisible(true);
    JPanel newpanel = new JPanel();
    newpanel.setSize(1300, 700);
    newpanel.add(chartPanel);
    Graph_Panel.add(newpanel);

}