Package de.ailis.xadrian.support

Examples of de.ailis.xadrian.support.TextRenderer


            }

            // Create the sector info text
            final Color titleColor = new Color(0x40, 0x40, 0x40);
            final Color detailColor = new Color(0x50, 0x50, 0x50);
            final TextRenderer textRenderer = new TextRenderer();
            Font font = UIManager.getFont("Label.font");
            if (font == null) font = new Font("Arial", Font.PLAIN, 12);
            textRenderer.setFont(font.deriveFont(Font.BOLD, font.getSize2D() * 1.2f / this.scale));
            textRenderer.setColor(titleColor);
            textRenderer.addText(this.overSector.getName());
            textRenderer.newLine();
            textRenderer.setFont(font.deriveFont(Font.PLAIN, font.getSize2D() / this.scale));
            textRenderer.setColor(detailColor);
            textRenderer.addText(String.format("%s: %d; %d", I18N
                .getString("component.sectorSelector.location"), this.overSector.getX(),
                this.overSector.getY()));
            textRenderer.newLine();
            textRenderer.addText(String.format("%s: %s", I18N
                .getString("component.sectorSelector.race"), this.overSector.getRace()
                .toString()));
            textRenderer.newLine();
            textRenderer.addText(String.format("%s: %s", I18N
                .getString("component.sectorSelector.suns"), this.overSector.getSuns()
                .toString()));

            addYieldInfo(textRenderer, this.overSector, "siliconWafers");
            addYieldInfo(textRenderer, this.overSector, "ore");
            addYieldInfo(textRenderer, this.overSector, "nividium");
            addYieldInfo(textRenderer, this.overSector, "ice");

            // Position the sector info text
            final Rectangle2D bounds = textRenderer.getBounds(g
                .getFontRenderContext());
            final int borderX = (int) (10 / this.scale);
            final int borderY = (int) (5 / this.scale);
            final int infoWidth = (int) (bounds.getWidth() + borderX * 2);
            final int infoHeight = (int) (bounds.getHeight() + borderY * 2);
            int infoLeft = sx * 100 - infoWidth / 2;
            int infoTop = sy * 100 + 100;
            if (infoTop + infoHeight > height / this.scale - 100)
                infoTop = sy * 100 - 100 - infoHeight;
            if (infoLeft < -50) infoLeft = -50;
            if (infoLeft + infoWidth > width / this.scale - 100)
                infoLeft = (int) (width / this.scale) - 100 - infoWidth;

            // Render the sector info text
            g.setColor(new Color(255, 255, 255, 200));
            g.fillRoundRect(infoLeft, infoTop, infoWidth, infoHeight, 30, 30);
            textRenderer.render(g, infoLeft + borderX, infoTop + borderY);
        }

        graphics.setColor(Color.BLACK);
        graphics.fillRect(0, 0, getWidth(), getHeight());
        graphics.drawImage(this.buffer, (getWidth() - width) / 2,
View Full Code Here

TOP

Related Classes of de.ailis.xadrian.support.TextRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.