Java Graphics Draw String drawSystemNameLabel(Graphics2D g, String sysName, Color color, double safetyOffset, boolean isLocationKnownUpToDate)

Here you can find the source of drawSystemNameLabel(Graphics2D g, String sysName, Color color, double safetyOffset, boolean isLocationKnownUpToDate)

Description

draw System Name Label

License

Open Source License

Parameter

Parameter Description
g a parameter
sysName a parameter
color a parameter
safetyOffset a parameter
isLocationKnownUpToDate a parameter

Declaration

public static final void drawSystemNameLabel(Graphics2D g, String sysName, Color color, double safetyOffset,
        boolean isLocationKnownUpToDate) 

Method Source Code


//package com.java2s;
/*/*  ww  w  .jav  a2s .  co  m*/
 * Copyright (c) 2004-2013 Universidade do Porto - Faculdade de Engenharia
 * Laborat?rio de Sistemas e Tecnologia Subaqu?tica (LSTS)
 * All rights reserved.
 * Rua Dr. Roberto Frias s/n, sala I203, 4200-465 Porto, Portugal
 *
 * This file is part of Neptus, Command and Control Framework.
 *
 * Commercial Licence Usage
 * Licencees holding valid commercial Neptus licences may use this file
 * in accordance with the commercial licence agreement provided with the
 * Software or, alternatively, in accordance with the terms contained in a
 * written agreement between you and Universidade do Porto. For licensing
 * terms, conditions, and further information contact lsts@fe.up.pt.
 *
 * European Union Public Licence - EUPL v.1.1 Usage
 * Alternatively, this file may be used under the terms of the EUPL,
 * Version 1.1 only (the "Licence"), appearing in the file LICENCE.md
 * included in the packaging of this file. You may not use this work
 * except in compliance with the Licence. Unless required by applicable
 * law or agreed to in writing, software distributed under the Licence is
 * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the Licence for the specific
 * language governing permissions and limitations at
 * https://www.lsts.pt/neptus/licence.
 *
 * For more information please see <http://lsts.fe.up.pt/neptus>.
 *
 * Author: Paulo Dias
 * 29/Jul/2012
 */

import java.awt.AlphaComposite;

import java.awt.Color;
import java.awt.Graphics2D;

public class Main {
    public static final int AGE_TRANSPARENCY = 128;

    /**
     * @param g
     * @param sysName
     * @param color
     * @param safetyOffset
     * @param isLocationKnownUpToDate
     */
    public static final void drawSystemNameLabel(Graphics2D g, String sysName, Color color, double safetyOffset,
            boolean isLocationKnownUpToDate) {
        Graphics2D g2 = (Graphics2D) g.create();

        int useTransparency = (isLocationKnownUpToDate ? 255 : AGE_TRANSPARENCY);
        if (useTransparency != 255)
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, useTransparency / 255f));

        g2.setColor(Color.BLACK);
        g2.drawString(sysName, (int) (12 * safetyOffset / 20) + 1, 1);
        g2.setColor(color);
        g2.drawString(sysName, (int) (12 * safetyOffset / 20), 0);
        g2.dispose();
    }
}

Related

  1. drawMessage(Graphics2D g, String message)
  2. drawRightJustifiedText(String text, int right, int y, Graphics g)
  3. drawRightText(Graphics g, String str, int x, int y, int width, int height)
  4. drawRotatedShape(final Shape shape, final Graphics2D g2, final float x, final float y, final double angle)
  5. drawScaleLabel(Graphics g, String label, int x, int y, boolean yAxisP)
  6. drawText(Graphics graphics, int x, int y, String text)
  7. drawText(Graphics2D graphics, Font font, Dimension2D dimension, String text)
  8. drawTextCenter(Graphics2D g2, String str, int x, int y)
  9. drawTextInBoundedArea(Graphics2D g2d, int x1, int y1, int x2, int y2, String text)