Example usage for java.awt Font deriveFont

List of usage examples for java.awt Font deriveFont

Introduction

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

Prototype

public Font deriveFont(int style, AffineTransform trans) 

Source Link

Document

Creates a new Font object by replicating this Font object and applying a new style and transform.

Usage

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/** Initializes the components composing the display. */
private void initComponents() {
    setLayout(new BorderLayout());
    setBackground(UIUtilities.BACKGROUND);
    setBorder(new SeparatorOneLineBorder());

    toReplace = new ArrayList<FileAnnotationData>();
    IconManager icons = IconManager.getInstance();
    filter = SHOW_ALL;//from  w  w  w. j av  a  2  s.c om
    filterButton = new JButton(NAMES[SHOW_ALL]);
    filterButton.setToolTipText("Filter tags and attachments.");
    UIUtilities.unifiedButtonLookAndFeel(filterButton);
    Font font = filterButton.getFont();
    filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));

    filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12));

    filterButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    filterButton.addMouseListener(new MouseAdapter() {

        /** 
         * Brings up the menu. 
         * @see MouseListener#mouseReleased(MouseEvent)
         */
        public void mouseReleased(MouseEvent me) {
            Object source = me.getSource();
            if (source instanceof Component)
                displayMenu((Component) source, me.getPoint());
        }

    });

    otherRating = new JLabel();
    otherRating.setBackground(UIUtilities.BACKGROUND_COLOR);
    font = otherRating.getFont();
    otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2));
    content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tagFlag = false;
    docFlag = false;
    otherFlag = false;
    tagNames = new ArrayList<String>();
    tagsDocList = new ArrayList<DocComponent>();
    filesDocList = new ArrayList<DocComponent>();
    otherList = new ArrayList<DocComponent>();
    existingTags = new HashMap<String, TagAnnotationData>();

    addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    UIUtilities.unifiedButtonLookAndFeel(addTagsButton);
    addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addTagsButton.setToolTipText("Add Tags.");
    addTagsButton.addActionListener(controller);
    addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS);
    addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addDocsButton.setToolTipText("Attach a document.");
    addDocsButton.addMouseListener(new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            if (addDocsButton.isEnabled()) {
                Point p = e.getPoint();
                createDocSelectionMenu().show(addDocsButton, p.x, p.y);
            }
        }

    });
    UIUtilities.unifiedButtonLookAndFeel(addDocsButton);

    removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeTagsButton);
    removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeTagsButton.setToolTipText("Remove Tags.");
    removeTagsButton.addMouseListener(controller);
    removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS);

    removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeDocsButton);
    removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeDocsButton.setToolTipText("Remove Attachments.");
    removeDocsButton.addMouseListener(controller);
    removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS);

    removeOtherAnnotationsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeOtherAnnotationsButton);
    removeOtherAnnotationsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeOtherAnnotationsButton.setToolTipText("Remove Annotations.");
    removeOtherAnnotationsButton.addMouseListener(controller);
    removeOtherAnnotationsButton.setActionCommand("" + EditorControl.REMOVE_OTHER_ANNOTATIONS);

    selectedValue = 0;
    initialValue = selectedValue;
    rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE);
    rating.setOpaque(false);
    rating.setBackground(UIUtilities.BACKGROUND_COLOR);
    rating.addPropertyChangeListener(this);
    unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(unrateButton);
    unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    unrateButton.setToolTipText("Unrate.");
    unrateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rating.setValue(0);
            view.saveData(true);
        }
    });
    tagsPane = new JPanel();
    tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS));
    tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    DocComponent doc = new DocComponent(null, model);
    tagsDocList.add(doc);
    tagsPane.add(doc);
    docPane = new JPanel();
    docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS));
    docPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    docRef = docPane;
    doc = new DocComponent(null, model);
    filesDocList.add(doc);
    docPane.add(doc);
    publishedBox = new JCheckBox();
    publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    publishedBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE);
        }
    });

    mapsPane = new MapAnnotationsComponent(model, view);

    otherPane = new JPanel();
    otherPane.setLayout(new GridBagLayout());
    otherPane.setBackground(UIUtilities.BACKGROUND_COLOR);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the well fields.//from   www  . j a v a2s.  c o m
 * 
 * @param well The well to handle.
 * @return See above.
 */
private JPanel layoutWellContent(WellData well) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = well.getWellType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_DESCRIPTION, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getExternalDescription();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the plate fields./*from w ww  . j  a va 2s .co  m*/
 * 
 * @param plate The plate to handle.
 * @return See above.
 */
private JPanel layoutPlateContent(PlateData plate) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = plate.getPlateType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_IDENTIFIER, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getExternalIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the screen fields./*w  ww .java 2s .  c  om*/
 * 
 * @param screen The screen to handle.
 * @return See above.
 */
private JPanel layoutScreenContent(ScreenData screen) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();

    l = UIUtilities.setTextFont("Protocol Identifier:", Font.BOLD, size);
    JLabel value = UIUtilities.createComponent(null);
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    String v = screen.getProtocolIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("Protocol Description:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = screen.getProtocolDescription();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("ReagentSet Identifier:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = screen.getReagentSetIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("ReagentSet Description:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    value.setFont(font.deriveFont(font.getStyle(), size));
    v = screen.getReagentSetDescripion();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    layoutComponents(content, components);
    return content;
}

From source file:org.rapidcontext.app.ui.ControlPanel.java

/**
 * Initializes the panel UI.//w w w  .j a  va 2  s  .co  m
 */
private void initialize() {
    Rectangle bounds = new Rectangle();
    GridBagConstraints c;
    JLabel label;
    Font font;
    Properties info;
    String str;

    // Set system UI looks
    if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ignore) {
            // Ah well... at least we tried.
        }
    }

    // Set title, menu & layout
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("RapidContext Server");
    setMenuBar(menuBar);
    initializeMenu();
    getContentPane().setLayout(new GridBagLayout());
    try {
        logotype = ImageIO.read(getClass().getResource("logotype.png"));
        Image img = ImageIO.read(getClass().getResource("logotype-icon-256x256.png"));
        setIconImage(img);
        if (SystemUtils.IS_OS_MAC_OSX) {
            MacApplication.get().setDockIconImage(img);
        }
    } catch (Exception ignore) {
        // Again, we only do our best effort here
    }

    // Add logotype
    c = new GridBagConstraints();
    c.gridheight = 5;
    c.insets = new Insets(6, 15, 10, 10);
    c.anchor = GridBagConstraints.NORTHWEST;
    Image small = logotype.getScaledInstance(128, 128, Image.SCALE_SMOOTH);
    getContentPane().add(new JLabel(new ImageIcon(small)), c);

    // Add link label
    c = new GridBagConstraints();
    c.gridx = 1;
    c.insets = new Insets(10, 10, 2, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(new JLabel("Server URL:"), c);
    serverLink.setText("http://localhost:" + server.port + "/");
    serverLink.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                AppUtils.openURL(serverLink.getText());
            } catch (Exception e) {
                error(e.getMessage());
            }
        }
    });
    c = new GridBagConstraints();
    c.gridx = 2;
    c.weightx = 1.0;
    c.insets = new Insets(10, 0, 2, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(serverLink, c);

    // Add login info label
    label = new JLabel("Login as 'admin' on a new server.");
    font = label.getFont();
    font = font.deriveFont(Font.ITALIC, font.getSize() - 2);
    label.setFont(font);
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 2;
    c.insets = new Insets(0, 0, 6, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(label, c);

    // Add status label
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 2;
    c.insets = new Insets(0, 10, 6, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(new JLabel("Status:"), c);
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 2;
    c.insets = new Insets(0, 0, 6, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(statusLabel, c);

    // Add version label
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 3;
    c.insets = new Insets(0, 10, 6, 10);
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(new JLabel("Version:"), c);
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 3;
    c.insets = new Insets(0, 0, 6, 10);
    c.anchor = GridBagConstraints.WEST;
    info = Main.buildInfo();
    str = info.getProperty("build.version") + " (built " + info.getProperty("build.date") + ")";
    getContentPane().add(new JLabel(str), c);

    // Add buttons
    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            start();
        }
    });
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 4;
    c.weighty = 1.0;
    c.insets = new Insets(0, 10, 10, 10);
    c.anchor = GridBagConstraints.SOUTH;
    getContentPane().add(startButton, c);
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            stop();
        }
    });
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 4;
    c.weighty = 1.0;
    c.insets = new Insets(0, 0, 10, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    getContentPane().add(stopButton, c);

    // Set size & position
    pack();
    bounds = this.getBounds();
    bounds.width = 470;
    bounds.x = 100;
    bounds.y = 100;
    setBounds(bounds);
}

From source file:com.aerohive.nms.web.config.lbs.services.HmFolderServiceImpl.java

private BufferedImage createFloorImage(HmFolder floor, double scale, int floorWidth, int floorHeight,
        Map<Long, Integer> channelMap, Map<Long, Integer> colorMap, int borderX, int borderY, double gridSize)
        throws Exception {
    BufferedImage image = new BufferedImage(floorWidth + borderX + 1, floorHeight + borderY + 1,
            BufferedImage.TYPE_INT_ARGB);
    if (floor == null) {
        return image;
    }//from ww w  . ja va 2  s .  com
    double metricWidth = 0.0, metricHeight = 0.0, offsetX = 0.0, offsetY = 0.0;
    int imageWidth = 0;
    LengthUnit lengthUnit = LengthUnit.METERS;

    if (null != floor.getMetricWidth()) {
        metricWidth = floor.getMetricWidth().doubleValue();
    }
    if (null != floor.getMetricHeight()) {
        metricHeight = floor.getMetricHeight().doubleValue();
    }
    if (null != floor.getImageWidth()) {
        imageWidth = floor.getImageWidth().intValue();
    }
    if (null != floor.getOffsetX()) {
        offsetX = floor.getOffsetX().doubleValue();
    }
    if (null != floor.getOffsetY()) {
        offsetY = floor.getOffsetY().doubleValue();
    }
    if (null != floor.getLengthUnit()) {
        lengthUnit = floor.getLengthUnit();
    }

    Graphics2D g2 = image.createGraphics();
    g2.setStroke(new BasicStroke(1));
    if (getDistanceMetric(metricWidth, lengthUnit) == 0) {
        g2.setColor(new Color(255, 255, 255));
        g2.fillRect(borderX, 0, floorWidth + 1, borderY);
        g2.fillRect(0, 0, borderX, borderY + floorHeight + 1);
        g2.setColor(new Color(120, 120, 120));
        g2.drawLine(0, borderY, floorWidth + borderX, borderY);
        g2.drawLine(borderX, 0, borderX, floorHeight + borderY);
        g2.setColor(new Color(255, 255, 204));
        g2.fillRect(borderX + 2, borderY + 2, 162, 25);
        g2.setColor(new Color(0, 51, 102));
        g2.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
        g2.drawString("Please size this floor plan.", borderX + 8, borderY + 19);
        return image;
    }
    double screenWidth = scale * getDistanceMetric(metricWidth, lengthUnit);
    double imageScale = screenWidth / imageWidth;
    int originX = (int) (getDistanceMetric(offsetX, lengthUnit) * scale);
    int originY = (int) (getDistanceMetric(offsetY, lengthUnit) * scale);
    g2.setColor(new Color(255, 255, 255));
    if (floor.getBackground() != null && floor.getBackground().length() > 0) {
        LinkedMultiValueMap<String, String> metadata = new LinkedMultiValueMap<>();
        String url = getImageBaseUrl(floor.getOwnerId()) + floor.getBackground();
        try {
            BufferedImage map = ImageIO.read(clientFileService.getFile(url, "AFS_TOKEN", metadata));
            AffineTransform transform = new AffineTransform();
            transform.scale(imageScale, imageScale);
            g2.drawImage(map, new AffineTransformOp(transform, null), getFloorX(0, borderX, originX),
                    getFloorY(0, borderY, originY));
        } catch (Exception e) {
            logger.error(String.format("image file not found with url: %s", url));
            double screenHeight = scale * getDistanceMetric(metricHeight, lengthUnit);
            g2.fillRect(getFloorX(0, borderX, originX), getFloorY(0, borderY, originY), (int) screenWidth,
                    (int) screenHeight);
        }
    } else {
        double screenHeight = scale * getDistanceMetric(metricHeight, lengthUnit);
        g2.fillRect(getFloorX(0, borderX, originX), getFloorY(0, borderY, originY), (int) screenWidth,
                (int) screenHeight);
    }
    g2.setColor(new Color(204, 204, 204));
    // Right edge border
    g2.drawLine(borderX + floorWidth, borderY + 1, borderX + floorWidth, borderY + floorHeight);
    // Left edge border (right of tick marks)
    g2.drawLine(borderX + 1, borderY + floorHeight, borderX + floorWidth, borderY + floorHeight);
    g2.setColor(new Color(255, 255, 255));
    g2.fillRect(borderX, 0, floorWidth + 1, borderY);
    g2.fillRect(0, 0, borderX, borderY + floorHeight + 1);
    g2.setColor(new Color(120, 120, 120));
    g2.drawLine(0, borderY, floorWidth + borderX, borderY);
    g2.drawLine(borderX, 0, borderX, floorHeight + borderY);

    Font font = new Font(Font.SANS_SERIF, Font.BOLD, 12);
    double actualWidth = floorWidth / scale;
    double actualHeight = floorHeight / scale;
    String firstLabel;
    double unitScale = scale;
    if (LengthUnit.FEET == lengthUnit) {
        firstLabel = "0 feet";
        actualWidth /= HmFolder.FEET_TO_METERS;
        actualHeight /= HmFolder.FEET_TO_METERS;
        unitScale *= HmFolder.FEET_TO_METERS;
    } else {
        firstLabel = "0 meters";
    }
    g2.drawString(firstLabel, borderX + 4, 12);
    double gridX = gridSize;
    while (gridX < actualWidth) {
        int x = (int) (gridX * unitScale) + borderX;
        g2.drawLine(x, 0, x, borderY);
        boolean label = true;
        if (gridX + gridSize >= actualWidth) {
            // Last mark
            if (x + getNumberPixelWidth(gridX) + 2 > floorWidth) {
                label = false;
            }
        }
        if (label) {
            g2.drawString("" + (int) gridX, x + 4, 12);
        }
        gridX += gridSize;
    }

    double gridY = 0;
    while (gridY < actualHeight) {
        int y = (int) (gridY * unitScale) + borderY;
        g2.drawLine(0, y, borderX, y);
        double lx = gridY;
        int dx = 1;
        for (int bx = borderX; bx >= 16; bx -= 7) {
            if (lx < 10) {
                dx += 7;
            } else {
                lx /= 10;
            }
        }
        boolean label = true;
        if (gridY + gridSize >= actualHeight) {
            // Last mark
            if (y - borderY + 13 > floorHeight) {
                label = false;
            }
        }
        if (label) {
            g2.drawString("" + (int) gridY, dx, y + 13);
        }
        gridY += gridSize;
    }

    double mapToImage = getMapToMetric(metricWidth, imageWidth, lengthUnit) * scale;
    if (floor.getPerimeter().size() > 0) {
        g2.setStroke(new BasicStroke(2));
        g2.setColor(new Color(2, 159, 245));
        int[] xPoints = new int[floor.getPerimeter().size()];
        int[] yPoints = new int[floor.getPerimeter().size()];
        int nPoints = 0;
        int perimId = floor.getPerimeter().get(0).getId();
        for (int i = 0; i < floor.getPerimeter().size(); i++) {
            HmVertex vertex = floor.getPerimeter().get(i);
            if (vertex.getId() != perimId) {
                g2.drawPolygon(xPoints, yPoints, nPoints);
                nPoints = 0;
                perimId = vertex.getId();
            }
            xPoints[nPoints] = getFloorX((int) (vertex.getX() * mapToImage), borderX, originX);
            yPoints[nPoints++] = getFloorY((int) (vertex.getY() * mapToImage), borderY, originY);
        }
        g2.drawPolygon(xPoints, yPoints, nPoints);
    }

    g2.setStroke(new BasicStroke(1));
    g2.setColor(new Color(0, 170, 0));
    g2.setFont(font.deriveFont(Font.BOLD, 11));

    List<HmDeviceLocationEx> devices = deviceLocationExRep.findAllHmDevices(floor.getId());
    if (null != devices && !devices.isEmpty()) {
        for (HmDeviceLocationEx device : devices) {
            double x = device.getX() * mapToImage;
            double y = device.getY() * mapToImage;
            createNodeImage(device.getId(), channelMap, colorMap, getFloorX((int) x, borderX, originX),
                    getFloorY((int) y, borderY, originY), g2);
        }
    } else {
        List<HmDevicePlanningEx> plannedDevices = devicePlanningExRep.findAllPlannedDevices(floor.getId());
        for (HmDevicePlanningEx plannedDevice : plannedDevices) {
            double x = plannedDevice.getX() * mapToImage;
            double y = plannedDevice.getY() * mapToImage;
            createNodeImage(plannedDevice.getId(), channelMap, colorMap, getFloorX((int) x, borderX, originX),
                    getFloorY((int) y, borderY, originY), g2);
        }
    }
    return image;
}