mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Thumbnail sometimes gets very small when uploading a project to the
cloud
This commit is contained in:
@@ -18,6 +18,7 @@ import javax.swing.JComponent;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -50,6 +51,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
private JPanel thumbnailPanel;
|
private JPanel thumbnailPanel;
|
||||||
private JTextField nameField;
|
private JTextField nameField;
|
||||||
private JComboBox categoryBox;
|
private JComboBox categoryBox;
|
||||||
|
private JScrollPane descriptionPane;
|
||||||
private JTextArea descriptionArea;
|
private JTextArea descriptionArea;
|
||||||
private JTextField keywordsField;
|
private JTextField keywordsField;
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
mainPanel.add(getDescriptionArea(), gbc);
|
mainPanel.add(getDescriptionPane(), gbc);
|
||||||
|
|
||||||
gbc.gridy = 3;
|
gbc.gridy = 3;
|
||||||
gbc.weighty = 0;
|
gbc.weighty = 0;
|
||||||
@@ -183,16 +185,21 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
paintThumbnail(g, getBounds());
|
paintThumbnail(g, getBounds());
|
||||||
}
|
}
|
||||||
}, gbc);
|
}, gbc);
|
||||||
Dimension d = UploadDialog.this.plugInPort.getCanvasDimensions(false);
|
|
||||||
if (d.height > d.width)
|
thumbnailPanel.setPreferredSize(getThumbnailSize());
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width / d.height, 192));
|
|
||||||
else
|
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192, 192 * d.height / d.width));
|
|
||||||
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||||
}
|
}
|
||||||
return thumbnailPanel;
|
return thumbnailPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dimension getThumbnailSize() {
|
||||||
|
Dimension d = UploadDialog.this.plugInPort.getCanvasDimensions(false);
|
||||||
|
if (d.height > d.width)
|
||||||
|
return new Dimension(192 * d.width / d.height, 192);
|
||||||
|
else
|
||||||
|
return new Dimension(192, 192 * d.height / d.width);
|
||||||
|
}
|
||||||
|
|
||||||
private JTextField getNameField() {
|
private JTextField getNameField() {
|
||||||
if (nameField == null) {
|
if (nameField == null) {
|
||||||
nameField = new JTextField();
|
nameField = new JTextField();
|
||||||
@@ -212,6 +219,15 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
return categoryBox;
|
return categoryBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JScrollPane getDescriptionPane() {
|
||||||
|
if (descriptionPane == null) {
|
||||||
|
descriptionPane = new JScrollPane(getDescriptionArea());
|
||||||
|
descriptionPane.setBorder(getNameField().getBorder());
|
||||||
|
descriptionPane.setPreferredSize(new Dimension(1, 128));
|
||||||
|
}
|
||||||
|
return descriptionPane;
|
||||||
|
}
|
||||||
|
|
||||||
private JTextArea getDescriptionArea() {
|
private JTextArea getDescriptionArea() {
|
||||||
if (descriptionArea == null) {
|
if (descriptionArea == null) {
|
||||||
descriptionArea = new HTMLTextArea();
|
descriptionArea = new HTMLTextArea();
|
||||||
@@ -223,7 +239,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
descriptionArea.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
descriptionArea.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
descriptionArea.setBorder(getNameField().getBorder());
|
descriptionArea.setBorder(null);
|
||||||
descriptionArea.setFont(getNameField().getFont());
|
descriptionArea.setFont(getNameField().getFont());
|
||||||
}
|
}
|
||||||
return descriptionArea;
|
return descriptionArea;
|
||||||
@@ -251,8 +267,8 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getThumbnail() {
|
public BufferedImage getThumbnail() {
|
||||||
BufferedImage thumbnailImage =
|
Dimension d = getThumbnailSize();
|
||||||
new BufferedImage(getThumbnailPanel().getWidth(), getThumbnailPanel().getHeight(), BufferedImage.TYPE_INT_RGB);
|
BufferedImage thumbnailImage = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
|
||||||
Graphics2D cg = thumbnailImage.createGraphics();
|
Graphics2D cg = thumbnailImage.createGraphics();
|
||||||
|
|
||||||
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(), thumbnailImage.getHeight()));
|
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(), thumbnailImage.getHeight()));
|
||||||
|
|||||||
@@ -1621,7 +1621,11 @@
|
|||||||
</versionNumber>
|
</versionNumber>
|
||||||
<releaseDate>2017-01-26 20:00:00.000 CET</releaseDate>
|
<releaseDate>2017-01-26 20:00:00.000 CET</releaseDate>
|
||||||
<name></name>
|
<name></name>
|
||||||
<changes>
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Thumbnail sometimes gets very small when uploading a project to the cloud</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Ability to change resistor shape (tubular or standard "dog bone")</description>
|
<description>Ability to change resistor shape (tubular or standard "dog bone")</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user