Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't print Masakari MC-J in either 0.1.59 or 0.41.24 #35

Closed
mhjacks opened this issue Oct 8, 2016 · 5 comments
Closed

Can't print Masakari MC-J in either 0.1.59 or 0.41.24 #35

mhjacks opened this issue Oct 8, 2016 · 5 comments
Labels
Milestone

Comments

@mhjacks
Copy link
Contributor

mhjacks commented Oct 8, 2016

The following NPE is reported the megameklab log:

java.lang.NullPointerException
at megameklab.com.ui.Mek.Printing.PrintMech.printImage(PrintMech.java:182)
at megameklab.com.ui.Mek.Printing.PrintMech.print(PrintMech.java:93)
at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2106)
at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1488)
at megameklab.com.ui.Mek.Printing.PrintMech.print(PrintMech.java:612)
at megameklab.com.util.UnitPrintManager.printAllUnits(UnitPrintManager.java:223)
at megameklab.com.util.UnitPrintManager.printEntity(UnitPrintManager.java:87)
at megameklab.com.util.MenuBarCreator.jMenuPrintCurrentUnit(MenuBarCreator.java:1019)
at megameklab.com.util.MenuBarCreator.access$1600(MenuBarCreator.java:66)
at megameklab.com.util.MenuBarCreator$27.actionPerformed(MenuBarCreator.java:428)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)

I should add that I'm running MML on Fedora 24, if that matters. I have been able to print units before.

@HammerGS
Copy link
Member

HammerGS commented Oct 8, 2016

Checking on a Windows machine I'm able to get things to print. Might be something OS specific but someone like @Dylan-M @arlith would need to double check. To help out I've attached the RS for you so you have it.

Masakari.pdf

EDIT:
Looking at the code (not the expert here) do you have a folder (data/images/recordsheets/) with image files in there. Too me, looks like something in there is missing.

@Dylan-M Dylan-M added the Bug label Oct 9, 2016
@Dylan-M Dylan-M added this to the Stable milestone Oct 9, 2016
@mhjacks
Copy link
Contributor Author

mhjacks commented Oct 25, 2016

I believe what we're dealing with is a straightforward case mismatch, which will work fine on Windows but will fail on Linux (and maybe MacOS?):

Looking at the code, we have:

           if (mech.getArmor(Mech.LOC_LLEG) > 0) {
                ImageHelper.loadSVGImage(new File("data/images/recordsheets/Armor_LLEG_"+mech.getArmor(Mech.LOC_LLEG)+"_Humanoid.svg")).render(g2d);
            }

Looking in the correponding directory we have:

-rw-r--r-- 1 mjackson mjackson 36452 Oct 15 10:01 Armor_LLeg_10_Humanoid.svg
-rw-r--r-- 1 mjackson mjackson 36980 Oct 15 10:01 Armor_LLeg_11_Humanoid.svg
-rw-r--r-- 1 mjackson mjackson 37482 Oct 15 10:01 Armor_LLeg_12_Humanoid.svg
-rw-r--r-- 1 mjackson mjackson 37985 Oct 15 10:01 Armor_LLeg_13_Humanoid.svg
-rw-r--r-- 1 mjackson mjackson 38467 Oct 15 10:01 Armor_LLeg_14_Humanoid.svg

I see the same potential issue with RLeg files and possibly others.

@mhjacks
Copy link
Contributor Author

mhjacks commented Oct 28, 2016

From grepping the source, it looks like this is the only place these things are referenced. I see two failrly obvious approaches to a fix here:

  1. Change the code to reference the filename as it appears on Linux (which will work on Mac and Windows too).
  2. Change the filenames to match what the code expects to find

Which would you prefer? I am happy to fork and propose a patch to fix this; what sort of patch would you prefer?

@Dylan-M
Copy link
Contributor

Dylan-M commented Oct 28, 2016

A pull request is fine, I assume it's the filename that needs to change if other filenames are all caps that way. If that isn't the case, then change the code instead.

@mhjacks
Copy link
Contributor Author

mhjacks commented Oct 28, 2016

Very well. The filenames in the git repo are all mixed case. I will work on a PR to change the code. Thanks!

Dylan-M added a commit that referenced this issue Oct 29, 2016
Fix #35 by normalizing references to files to use the names of the data files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants