Search in sources :

Example 6 with SVGException

use of com.kitfox.svg.SVGException in project megameklab by MegaMek.

the class PrintProtomech method printImage.

public void printImage(Graphics2D g2d, PageFormat pageFormat) {
    if ((null == g2d) || (null == protoMech)) {
        return;
    }
    currentMargin = 0;
    // g2d.drawImage(ImageHelper.getRecordSheet(protoMech, false), 18, 18,
    // 558, 738, null);
    int stop = Math.min(5, protoMechList.size() - currentPosition);
    for (int pos = 1; pos <= stop; pos++) {
        protoMech = protoMechList.get((pos + currentPosition) - 1);
        try {
            ImageHelper.loadSVGImage(new File("data/images/recordsheets/ProtomechTemplate" + pos + ".svg")).render(g2d);
        } catch (SVGException e) {
            e.printStackTrace();
        }
        g2d.setColor(Color.BLACK);
        printProtomechData(g2d);
        printWeaponsNEquipment(g2d);
        drawArmor(g2d);
        currentMargin += pageMarginBase;
    }
    System.gc();
    Font font = UnitUtil.deriveFont(true, 6.5f);
    g2d.setFont(font);
    g2d.drawString(Integer.toString(Calendar.getInstance().get(Calendar.YEAR)), 119f, 759.5f);
    g2d.drawImage(ImageHelper.getFluffImage(protoMech, ImageHelper.imageProto), 410, 23, 35, 45, null);
    g2d.scale(pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
}
Also used : SVGException(com.kitfox.svg.SVGException) File(java.io.File) Font(java.awt.Font)

Example 7 with SVGException

use of com.kitfox.svg.SVGException in project megameklab by MegaMek.

the class PrintBattleArmor method printImage.

public void printImage(Graphics2D g2d, PageFormat pageFormat) {
    if ((null == g2d) || (null == battleArmor)) {
        return;
    }
    isAdvanced = false;
    currentMargin = 0;
    try {
        ImageHelper.loadSVGImage(new File("data/images/recordsheets/BA/BATemplate.svg")).render(g2d);
    } catch (SVGException e) {
        e.printStackTrace();
    }
    g2d.drawImage(ImageHelper.getFluffImage(battleArmor, ImageHelper.imageBattleArmor), 420, 20, 25, 45, null);
    int stop = Math.min(5, battleArmorList.size() - currentPosition);
    for (int pos = 0; pos < stop; pos++) {
        battleArmor = battleArmorList.get(pos + currentPosition);
        int squadNumber = pos + 1;
        try {
            ImageHelper.loadSVGImage(new File("data/images/recordsheets/BA/Squad" + squadNumber + "_" + battleArmor.getTroopers() + ".svg")).render(g2d);
        } catch (SVGException e) {
            e.printStackTrace();
        }
        printBattleArmorData(g2d, squadNumber);
        if (battleArmor.getArmor(1) > 0) {
            try {
                ImageHelper.loadSVGImage(new File("data/images/recordsheets/BA/Squad" + squadNumber + "_" + battleArmor.getTroopers() + "_" + battleArmor.getArmor(1) + ".svg")).render(g2d);
            } catch (SVGException e) {
                e.printStackTrace();
            }
        }
        printWeaponsNEquipment(g2d);
        currentMargin += pageMarginBase;
    }
    System.gc();
    Font font = UnitUtil.deriveFont(true, 6);
    g2d.setFont(font);
    g2d.drawString(Integer.toString(Calendar.getInstance().get(Calendar.YEAR)), 41f, 769.5f);
    g2d.scale(pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
}
Also used : SVGException(com.kitfox.svg.SVGException) File(java.io.File) Font(java.awt.Font)

Example 8 with SVGException

use of com.kitfox.svg.SVGException in project pivot by apache.

the class TestPanel method initComponents.

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
    panelDisplay = new javax.swing.JPanel();
    button1 = new javax.swing.JButton();
    button2 = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    panelDisplay.setLayout(new java.awt.BorderLayout());
    getContentPane().add(panelDisplay, java.awt.BorderLayout.CENTER);
    button1.setText("Visible");
    button1.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SVGElement root = Pivot964Swing.this.panel.root;
            try {
                root.setAttribute("viewBox", AnimationElement.AT_XML, "0 0 2368 1652");
                root.updateTime(0f);
                repaint();
            } catch (SVGElementException e) {
                e.printStackTrace();
            } catch (SVGException e) {
                e.printStackTrace();
            }
        }
    });
    button2.setText("Invisible");
    button2.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            SVGElement root = Pivot964Swing.this.panel.root;
            try {
                root.setAttribute("viewBox", AnimationElement.AT_XML, "800 0 2368 1652");
                root.updateTime(0f);
                repaint();
            } catch (SVGElementException e) {
                e.printStackTrace();
            } catch (SVGException e) {
                e.printStackTrace();
            }
        }
    });
    panelDisplay.add(button1, java.awt.BorderLayout.EAST);
    panelDisplay.add(button2, java.awt.BorderLayout.WEST);
    pack();
}
Also used : SVGElement(com.kitfox.svg.SVGElement) SVGException(com.kitfox.svg.SVGException) SVGElementException(com.kitfox.svg.SVGElementException) BorderLayout(java.awt.BorderLayout) JPanel(javax.swing.JPanel)

Aggregations

SVGException (com.kitfox.svg.SVGException)8 File (java.io.File)5 SVGElementException (com.kitfox.svg.SVGElementException)3 Font (java.awt.Font)3 SVGDiagram (com.kitfox.svg.SVGDiagram)1 SVGElement (com.kitfox.svg.SVGElement)1 SVGRoot (com.kitfox.svg.SVGRoot)1 Text (com.kitfox.svg.Text)1 Tspan (com.kitfox.svg.Tspan)1 BorderLayout (java.awt.BorderLayout)1 ArrayList (java.util.ArrayList)1 StringJoiner (java.util.StringJoiner)1 JPanel (javax.swing.JPanel)1 AmmoType (megamek.common.AmmoType)1 EquipmentType (megamek.common.EquipmentType)1 Mounted (megamek.common.Mounted)1 SuperHeavyTank (megamek.common.SuperHeavyTank)1 WeaponType (megamek.common.WeaponType)1 ArtilleryWeapon (megamek.common.weapons.artillery.ArtilleryWeapon)1 InfantryWeapon (megamek.common.weapons.infantry.InfantryWeapon)1