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();
}
}
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();
}
}
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();
}
}
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();
}
}
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) {
}
}
Aggregations