Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicho92 committed Mar 3, 2019
1 parent f9286e4 commit d8fc472
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
21 changes: 14 additions & 7 deletions src/main/java/org/magic/gui/components/PackagesBrowserPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.magic.services.MTGControler;
import org.magic.services.extra.BoosterPicturesProvider;
import org.magic.tools.UITools;
import java.awt.FlowLayout;

public class PackagesBrowserPanel extends MTGUIComponent{

Expand All @@ -41,25 +42,31 @@ public PackagesBrowserPanel() {
private void initGUI() {
setLayout(new BorderLayout(0, 0));
model = new DefaultTreeModel(new DefaultMutableTreeNode("Packaging"));
tree = new JTree(model);
JComboBox<MagicEdition> cboEditions = UITools.createComboboxEditions();
panelDraw = new ZoomableJPanel() ;
JScrollPane scrollPane = new JScrollPane(tree);
scrollPane.setPreferredSize(new Dimension(150, 322));
add(scrollPane, BorderLayout.WEST);
add(panelDraw, BorderLayout.CENTER);

JPanel panel = new JPanel();
add(panel, BorderLayout.NORTH);
panel.add(cboEditions);
cboEditions.addItemListener(it->setMagicEdition((MagicEdition)cboEditions.getSelectedItem()));
panel.setLayout(new BorderLayout(0, 0));


panel.add(cboEditions,BorderLayout.NORTH);

add(panel, BorderLayout.WEST);



tree = new JTree(model);
tree.setShowsRootHandles(false);
panel.add(new JScrollPane(tree),BorderLayout.CENTER);

tree.addTreeSelectionListener(e-> {
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();

if(selectedNode!=null && (selectedNode.getUserObject() instanceof Packaging))
load((Packaging)selectedNode.getUserObject());
});
cboEditions.addItemListener(it->setMagicEdition((MagicEdition)cboEditions.getSelectedItem()));


}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/magic/gui/components/ZoomableJPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

public class ZoomableJPanel extends JPanel implements MouseWheelListener, MouseListener, MouseMotionListener {

protected BufferedImage img=null;

private static final long serialVersionUID = 1L;

protected transient BufferedImage img=null;

private double zoomFactor = 1;
private double prevZoomFactor = 1;
Expand All @@ -39,6 +42,7 @@ public ZoomableJPanel() {
public void setImg(BufferedImage img)
{
this.img=img;

}

private void initComponent() {
Expand All @@ -54,9 +58,9 @@ public void paintComponent(Graphics g) {
if(img==null)
return;


Graphics2D g2 = (Graphics2D) g;



if (zoomer) {
AffineTransform at = new AffineTransform();

Expand Down Expand Up @@ -90,9 +94,9 @@ public void paintComponent(Graphics g) {
}

// All drawings go here

g2.drawImage(ImageTools.trimAlpha(img), 0, 0, this);



}

@Override
Expand Down

0 comments on commit d8fc472

Please sign in to comment.