Search in sources :

Example 6 with MechView

use of megamek.common.MechView in project megameklab by MegaMek.

the class PreviewTab method refresh.

public void refresh() {
    boolean populateTextFields = true;
    MechView mechView = null;
    try {
        mechView = new MechView(getMech(), false);
    } catch (Exception e) {
        e.printStackTrace();
        // error unit didn't load right. this is bad news.
        populateTextFields = false;
    }
    if (populateTextFields && (mechView != null)) {
        panelMekView.setMech(getMech());
    } else {
        panelMekView.reset();
    }
}
Also used : MechView(megamek.common.MechView)

Example 7 with MechView

use of megamek.common.MechView in project megameklab by MegaMek.

the class PreviewTab method refresh.

public void refresh() {
    boolean populateTextFields = true;
    MechView mechView = null;
    try {
        mechView = new MechView(getAero(), false);
    } catch (Exception e) {
        e.printStackTrace();
        // error unit didn't load right. this is bad news.
        populateTextFields = false;
    }
    if (populateTextFields && (mechView != null)) {
        panelMekView.setMech(getAero());
    } else {
        panelMekView.reset();
    }
}
Also used : MechView(megamek.common.MechView)

Example 8 with MechView

use of megamek.common.MechView in project megameklab by MegaMek.

the class StructureTab method refreshPreview.

public void refreshPreview() {
    boolean populateTextFields = true;
    MechView mechView = null;
    try {
        mechView = new MechView(getBattleArmor(), false);
    } catch (Exception e) {
        e.printStackTrace();
        // error unit didn't load right. this is bad news.
        populateTextFields = false;
    }
    if (populateTextFields && (mechView != null)) {
        panelMekView.setMech(getBattleArmor());
    } else {
        panelMekView.reset();
    }
}
Also used : MechView(megamek.common.MechView) LocationFullException(megamek.common.LocationFullException)

Example 9 with MechView

use of megamek.common.MechView in project megameklab by MegaMek.

the class PreviewTab method refresh.

public void refresh() {
    boolean populateTextFields = true;
    MechView mechView = null;
    try {
        mechView = new MechView(getTank(), false);
    } catch (Exception e) {
        e.printStackTrace();
        // error unit didn't load right. this is bad news.
        populateTextFields = false;
    }
    if (populateTextFields && (mechView != null)) {
        panelMekView.setMech(getTank());
    } else {
        panelMekView.reset();
    }
}
Also used : MechView(megamek.common.MechView)

Example 10 with MechView

use of megamek.common.MechView in project megameklab by MegaMek.

the class UnitUtil method showUnitSpecs.

public static void showUnitSpecs(Entity unit, JFrame frame) {
    HTMLEditorKit kit = new HTMLEditorKit();
    MechView mechView = null;
    try {
        mechView = new MechView(unit, true);
    } catch (Exception e) {
    // error unit didn't load right. this is bad news.
    }
    StringBuffer unitSpecs = new StringBuffer("<html><body>");
    unitSpecs.append(mechView.getMechReadoutBasic());
    unitSpecs.append(mechView.getMechReadoutLoadout());
    unitSpecs.append("</body></html>");
    // System.err.println(unitSpecs.toString());
    JEditorPane textPane = new JEditorPane("text/html", "");
    JScrollPane scroll = new JScrollPane();
    textPane.setEditable(false);
    textPane.setCaret(new DefaultCaret());
    textPane.setEditorKit(kit);
    scroll.setViewportView(textPane);
    scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.getVerticalScrollBar().setUnitIncrement(20);
    textPane.setText(unitSpecs.toString());
    scroll.setVisible(true);
    JDialog jdialog = new JDialog();
    jdialog.add(scroll);
    /*
         * if (unit instanceof Mech) { EntityVerifier entityVerifier = new
         * EntityVerifier(new File("data/mechfiles/UnitVerifierOptions.xml"));
         * //$NON-NLS-1$ TestMech test = new TestMech((Mech)unit,
         * entityVerifier.mechOption, null); JEditorPane pane2 = new
         * JEditorPane();
         * pane2.setText(test.printWeightCalculation().toString());
         * jdialog.add(pane2); }
         */
    Dimension size = new Dimension(CConfig.getIntParam("WINDOWWIDTH") / 2, CConfig.getIntParam("WINDOWHEIGHT"));
    jdialog.setPreferredSize(size);
    jdialog.setMinimumSize(size);
    scroll.setPreferredSize(size);
    scroll.setMinimumSize(size);
    // text.setPreferredSize(size);
    jdialog.setLocationRelativeTo(frame);
    jdialog.setVisible(true);
    try {
        textPane.setSelectionStart(0);
        textPane.setSelectionEnd(0);
    } catch (Exception ex) {
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) MechView(megamek.common.MechView) DefaultCaret(javax.swing.text.DefaultCaret) JEditorPane(javax.swing.JEditorPane) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Dimension(java.awt.Dimension) LocationFullException(megamek.common.LocationFullException) JDialog(javax.swing.JDialog)

Aggregations

MechView (megamek.common.MechView)10 FileDialog (java.awt.FileDialog)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 PrintStream (java.io.PrintStream)2 LocationFullException (megamek.common.LocationFullException)2 BLKFile (megamek.common.loaders.BLKFile)2 Dimension (java.awt.Dimension)1 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1 JDialog (javax.swing.JDialog)1 JEditorPane (javax.swing.JEditorPane)1 JScrollPane (javax.swing.JScrollPane)1 DefaultCaret (javax.swing.text.DefaultCaret)1 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)1