[Git][java-team/sweethome3d-furniture-editor][upstream] New upstream version 1.24
Markus Koschany
gitlab at salsa.debian.org
Mon Jan 28 16:11:58 GMT 2019
Markus Koschany pushed to branch upstream at Debian Java Maintainers / sweethome3d-furniture-editor
Commits:
edf0f687 by Markus Koschany at 2019-01-28T15:58:51Z
New upstream version 1.24
- - - - -
8 changed files:
- README.TXT
- build.xml
- src/com/eteks/furniturelibraryeditor/swing/EditorPane.java
- src/com/eteks/furniturelibraryeditor/swing/FurnitureLibraryTable.java
- src/com/eteks/furniturelibraryeditor/swing/FurnitureLibraryUserPreferencesPanel.java
- src/com/eteks/furniturelibraryeditor/swing/FurniturePanel.java
- src/com/eteks/furniturelibraryeditor/swing/package.properties
- src/com/eteks/furniturelibraryeditor/swing/package_fr.properties
Changes:
=====================================
README.TXT
=====================================
@@ -1,18 +1,18 @@
-FURNITURE LIBRARY EDITOR v 1.23
+FURNITURE LIBRARY EDITOR v 1.24
-------------------------------
This archive contains source code of the Furniture Library Editor for Sweet Home 3D.
You may also download this source code with the following SVN command:
-svn checkout https://svn.code.sf.net/p/sweethome3d/code/tags/V_1_23/FurnitureLibraryEditor FurnitureLibraryEditor
+svn checkout https://svn.code.sf.net/p/sweethome3d/code/tags/V_1_24/FurnitureLibraryEditor FurnitureLibraryEditor
As this project depends on Sweet Home 3D, download and install also Sweet Home 3D source code from
-http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-6.0-src.zip
+http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-6.1-src.zip
or with the following SVN command:
-svn checkout https://svn.code.sf.net/p/sweethome3d/code/tags/V_6_0/SweetHome3D SweetHome3D
+svn checkout https://svn.code.sf.net/p/sweethome3d/code/tags/V_6_1/SweetHome3D SweetHome3D
HOW TO USE THIS SOURCE CODE
=====================================
build.xml
=====================================
@@ -10,7 +10,7 @@
-->
<project basedir="." default="furnitureLibraryEditorJarExecutable" name="FurnitureLibraryEditor">
<!-- The current version of the Furniture Library Editor -->
- <property name="version" value="1.23"/>
+ <property name="version" value="1.24"/>
<target name="furnitureLibraryEditor"
description="Builds build/FurnitureLibraryEditor.jar with all its classes">
=====================================
src/com/eteks/furniturelibraryeditor/swing/EditorPane.java
=====================================
@@ -51,12 +51,13 @@ import com.eteks.sweethome3d.model.SelectionListener;
import com.eteks.sweethome3d.model.UserPreferences;
import com.eteks.sweethome3d.swing.ControllerAction;
import com.eteks.sweethome3d.swing.ResourceAction;
+import com.eteks.sweethome3d.swing.SwingTools;
import com.eteks.sweethome3d.swing.UnfocusableToolBar;
import com.eteks.sweethome3d.tools.OperatingSystem;
import com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer;
/**
- * The main pane that displays Furniture Library Editor.
+ * The main pane that displays Furniture Library Editor.
* @author Emmanuel Puybaret
*/
public class EditorPane extends JRootPane implements EditorView {
@@ -68,18 +69,18 @@ public class EditorPane extends JRootPane implements EditorView {
EditorController controller) {
this.preferences = preferences;
createActions(controller, preferences);
-
+
// Layout components
JComponent furnitureLibraryView = (JComponent)controller.getFurnitureLibraryController().getView();
JScrollPane furnitureLibraryScrollPane = new JScrollPane(furnitureLibraryView);
JViewport viewport = furnitureLibraryScrollPane.getViewport();
- viewport.setTransferHandler(furnitureLibraryView.getTransferHandler());
+ viewport.setTransferHandler(furnitureLibraryView.getTransferHandler());
JPopupMenu furnitureLibraryPopupMenu = createFurnitureLibraryPopupMenu(preferences, controller);
furnitureLibraryView.setComponentPopupMenu(furnitureLibraryPopupMenu);
viewport.setComponentPopupMenu(furnitureLibraryPopupMenu);
getContentPane().add(furnitureLibraryScrollPane);
getContentPane().add(createToolBar(preferences, controller), BorderLayout.NORTH);
-
+
// Map Enter accelerator of furniture library to furniture modification action
furnitureLibraryView.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), ActionType.MODIFY_FURNITURE);
furnitureLibraryView.getActionMap().put(ActionType.MODIFY_FURNITURE, getActionMap().get(ActionType.MODIFY_FURNITURE));
@@ -91,47 +92,47 @@ public class EditorPane extends JRootPane implements EditorView {
});
}
- private void createActions(EditorController controller,
+ private void createActions(EditorController controller,
UserPreferences preferences) {
ActionMap actionMap = getActionMap();
try {
actionMap.put(ActionType.NEW_LIBRARY, new ControllerAction(
- preferences, EditorPane.class, ActionType.NEW_LIBRARY.name(), true,
+ preferences, EditorPane.class, ActionType.NEW_LIBRARY.name(), true,
controller, "newLibrary"));
actionMap.put(ActionType.OPEN, new ControllerAction(
- preferences, EditorPane.class, ActionType.OPEN.name(), true,
+ preferences, EditorPane.class, ActionType.OPEN.name(), true,
controller, "open"));
actionMap.put(ActionType.MERGE, new ControllerAction(
- preferences, EditorPane.class, ActionType.MERGE.name(), true,
+ preferences, EditorPane.class, ActionType.MERGE.name(), true,
controller, "merge"));
actionMap.put(ActionType.SAVE, new ControllerAction(
- preferences, EditorPane.class, ActionType.SAVE.name(), true,
+ preferences, EditorPane.class, ActionType.SAVE.name(), true,
controller, "save"));
actionMap.put(ActionType.SAVE_AS, new ControllerAction(
- preferences, EditorPane.class, ActionType.SAVE_AS.name(), true,
+ preferences, EditorPane.class, ActionType.SAVE_AS.name(), true,
controller, "saveAs"));
actionMap.put(ActionType.PREFERENCES, new ControllerAction(
- preferences, EditorPane.class, ActionType.PREFERENCES.name(), true,
+ preferences, EditorPane.class, ActionType.PREFERENCES.name(), true,
controller, "editPreferences"));
actionMap.put(ActionType.EXIT, new ControllerAction(
- preferences, EditorPane.class, ActionType.EXIT.name(), true,
+ preferences, EditorPane.class, ActionType.EXIT.name(), true,
controller, "exit"));
FurnitureLibraryController furnitureLibraryController = controller.getFurnitureLibraryController();
actionMap.put(ActionType.IMPORT_FURNITURE, new ControllerAction(
- preferences, EditorPane.class, ActionType.IMPORT_FURNITURE.name(), true,
+ preferences, EditorPane.class, ActionType.IMPORT_FURNITURE.name(), true,
furnitureLibraryController, "importFurniture"));
boolean selectionEmpty = furnitureLibraryController.getSelectedFurniture().isEmpty();
actionMap.put(ActionType.MODIFY_FURNITURE, new ControllerAction(
- preferences, EditorPane.class, ActionType.MODIFY_FURNITURE.name(), !selectionEmpty,
+ preferences, EditorPane.class, ActionType.MODIFY_FURNITURE.name(), !selectionEmpty,
furnitureLibraryController, "modifySelectedFurniture"));
actionMap.put(ActionType.DELETE, new ControllerAction(
- preferences, EditorPane.class, ActionType.DELETE.name(), !selectionEmpty,
+ preferences, EditorPane.class, ActionType.DELETE.name(), !selectionEmpty,
furnitureLibraryController, "deleteSelectedFurniture"));
actionMap.put(ActionType.SELECT_ALL, new ControllerAction(
- preferences, EditorPane.class, ActionType.SELECT_ALL.name(), true,
+ preferences, EditorPane.class, ActionType.SELECT_ALL.name(), true,
furnitureLibraryController, "selectAll"));
actionMap.put(ActionType.ABOUT, new ControllerAction(
- preferences, EditorPane.class, ActionType.ABOUT.name(), true,
+ preferences, EditorPane.class, ActionType.ABOUT.name(), true,
controller, "about"));
} catch (NoSuchMethodException ex) {
throw new IllegalArgumentException(ex);
@@ -166,13 +167,13 @@ public class EditorPane extends JRootPane implements EditorView {
}
/**
- * Adds to tool bar the button matching the given <code>actionType</code>.
+ * Adds to tool bar the button matching the given <code>actionType</code>.
*/
private void addActionToToolBar(ActionType actionType,
JToolBar toolBar) {
Action action = new ResourceAction.ToolBarAction(getActionMap().get(actionType));
if (OperatingSystem.isMacOSXLeopardOrSuperior() && OperatingSystem.isJavaVersionGreaterOrEqual("1.7")) {
- // Add a button with higher insets to ensure the top and bottom of segmented buttons are correctly drawn
+ // Add a button with higher insets to ensure the top and bottom of segmented buttons are correctly drawn
toolBar.add(new JButton(new ResourceAction.ToolBarAction(action)) {
@Override
public Insets getInsets() {
@@ -186,7 +187,7 @@ public class EditorPane extends JRootPane implements EditorView {
toolBar.add(new JButton(new ResourceAction.ToolBarAction(action)));
}
}
-
+
/**
* Returns the popup menu of the furniture library view.
*/
@@ -216,18 +217,18 @@ public class EditorPane extends JRootPane implements EditorView {
/**
* Displays a dialog that lets user choose whether he wants to save before closing or not.
- * @return {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#SAVE}
+ * @return {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#SAVE}
* if the user chose to save furniture library,
- * {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#DO_NOT_SAVE}
+ * {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#DO_NOT_SAVE}
* if he doesn't want to save furniture library,
- * or {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#CANCEL}
+ * or {@link com.eteks.sweethome3d.viewcontroller.HomeView.SaveAnswer#CANCEL}
* if he doesn't want to continue current operation.
*/
public SaveAnswer confirmSave(String homeName) {
// Retrieve displayed text in buttons and message
String message;
if (homeName != null) {
- message = this.preferences.getLocalizedString(EditorPane.class, "confirmSave.message",
+ message = this.preferences.getLocalizedString(EditorPane.class, "confirmSave.message",
"\"" + homeName + "\"");
} else {
message = this.preferences.getLocalizedString(EditorPane.class, "confirmSave.message", "");
@@ -237,7 +238,7 @@ public class EditorPane extends JRootPane implements EditorView {
String doNotSave = this.preferences.getLocalizedString(EditorPane.class, "confirmSave.doNotSave");
String cancel = this.preferences.getLocalizedString(EditorPane.class, "confirmSave.cancel");
- switch (JOptionPane.showOptionDialog(SwingUtilities.getRootPane(this), message, title,
+ switch (JOptionPane.showOptionDialog(SwingUtilities.getRootPane(this), message, title,
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
null, new Object [] {save, doNotSave, cancel}, save)) {
// Convert showOptionDialog answer to SaveAnswer enum constants
@@ -255,15 +256,18 @@ public class EditorPane extends JRootPane implements EditorView {
public void showAboutDialog() {
String messageFormat = this.preferences.getLocalizedString(EditorPane.class, "about.message");
String version = this.preferences.getLocalizedString(EditorPane.class, "about.version");
- String message = String.format(messageFormat, version, System.getProperty("java.version"));
+ String message = String.format(messageFormat, version, System.getProperty("java.version"));
// Use an uneditable editor pane to let user select text in dialog
JEditorPane messagePane = new JEditorPane("text/html", message);
messagePane.setOpaque(false);
messagePane.setEditable(false);
+ if (SwingTools.getResolutionScale() != 1) {
+ messagePane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
+ }
String title = this.preferences.getLocalizedString(EditorPane.class, "about.title");
Icon icon = new ImageIcon(EditorPane.class.getResource(
this.preferences.getLocalizedString(EditorPane.class, "about.icon")));
- JOptionPane.showMessageDialog(SwingUtilities.getRootPane(this),
+ JOptionPane.showMessageDialog(SwingUtilities.getRootPane(this),
messagePane, title, JOptionPane.INFORMATION_MESSAGE, icon);
}
=====================================
src/com/eteks/furniturelibraryeditor/swing/FurnitureLibraryTable.java
=====================================
@@ -75,6 +75,7 @@ import com.eteks.sweethome3d.model.SelectionListener;
import com.eteks.sweethome3d.model.UserPreferences;
import com.eteks.sweethome3d.swing.CatalogItemToolTip;
import com.eteks.sweethome3d.swing.IconManager;
+import com.eteks.sweethome3d.swing.SwingTools;
import com.eteks.sweethome3d.viewcontroller.View;
/**
@@ -92,6 +93,11 @@ public class FurnitureLibraryTable extends JTable implements View {
super(new FurnitureLibraryTableModel(furnitureLibrary, furnitureLanguageController),
new FurnitureLibraryTableColumnModel(furnitureLibrary, preferences, furnitureLanguageController));
this.toolTip = new CatalogItemToolTip(CatalogItemToolTip.DisplayedInformation.ICON, preferences);
+ float resolutionScale = SwingTools.getResolutionScale();
+ if (resolutionScale != 1) {
+ // Adapt row height to specified resolution scale
+ setRowHeight(Math.round(getRowHeight() * resolutionScale));
+ }
addTableHeaderListener();
setAutoResizeMode(AUTO_RESIZE_OFF);
updateTableColumnsWidth();
@@ -103,10 +109,10 @@ public class FurnitureLibraryTable extends JTable implements View {
}
addUserPreferencesListener(preferences);
}
-
+
/**
* Adds a listener to <code>preferences</code> to repaint this table
- * and its header when unit changes.
+ * and its header when unit changes.
*/
private void addUserPreferencesListener(UserPreferences preferences) {
preferences.addPropertyChangeListener(
@@ -115,7 +121,7 @@ public class FurnitureLibraryTable extends JTable implements View {
/**
* Preferences property listener bound to this table with a weak reference to avoid
- * strong link between user preferences and this table.
+ * strong link between user preferences and this table.
*/
private static class UserPreferencesChangeListener implements PropertyChangeListener {
private WeakReference<FurnitureLibraryTable> furnitureLibraryTable;
@@ -123,7 +129,7 @@ public class FurnitureLibraryTable extends JTable implements View {
public UserPreferencesChangeListener(FurnitureLibraryTable furnitureTable) {
this.furnitureLibraryTable = new WeakReference<FurnitureLibraryTable>(furnitureTable);
}
-
+
public void propertyChange(PropertyChangeEvent ev) {
// If furniture table was garbage collected, remove this listener from preferences
FurnitureLibraryTable furnitureLibraryTable = this.furnitureLibraryTable.get();
@@ -140,10 +146,10 @@ public class FurnitureLibraryTable extends JTable implements View {
/**
* Adds selection listeners to this table.
*/
- private void addSelectionListeners(final FurnitureLibraryController controller) {
+ private void addSelectionListeners(final FurnitureLibraryController controller) {
final SelectionListener controllerSelectionListener = new SelectionListener() {
public void selectionChanged(SelectionEvent ev) {
- setSelectedFurniture(controller.getSelectedFurniture());
+ setSelectedFurniture(controller.getSelectedFurniture());
}
};
this.tableSelectionListener = new ListSelectionListener () {
@@ -187,7 +193,7 @@ public class FurnitureLibraryTable extends JTable implements View {
* Adds a mouse listener on table header that will sort furniture.
*/
private void addTableHeaderListener() {
- // Sort on click in column header
+ // Sort on click in column header
getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent ev) {
@@ -199,7 +205,7 @@ public class FurnitureLibraryTable extends JTable implements View {
int columnIndex = getTableHeader().columnAtPoint(ev.getPoint());
Object columnIdentifier = getColumnModel().getColumn(columnIndex).getIdentifier();
if (columnIdentifier instanceof String) {
- String propertyKey = (String)columnIdentifier;
+ String propertyKey = (String)columnIdentifier;
if (columnIdentifier.equals(tableModel.getSortProperty())) {
if (tableModel.isDescendingOrder()) {
tableModel.setSortProperty(null);
@@ -218,7 +224,7 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Selects furniture in table.
+ * Selects furniture in table.
*/
private void setSelectedFurniture(List<CatalogPieceOfFurniture> selectedFurniture) {
getSelectionModel().removeListSelectionListener(this.tableSelectionListener);
@@ -230,7 +236,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece instanceof CatalogPieceOfFurniture) {
// Search index of piece in sorting table model
int index = tableModel.getPieceOfFurnitureIndex((CatalogPieceOfFurniture)piece);
- // If the piece was found (during the addition of a piece to library, the model may not be updated yet)
+ // If the piece was found (during the addition of a piece to library, the model may not be updated yet)
if (index != -1) {
addRowSelectionInterval(index, index);
minIndex = Math.min(minIndex, index);
@@ -243,16 +249,16 @@ public class FurnitureLibraryTable extends JTable implements View {
}
getSelectionModel().addListSelectionListener(this.tableSelectionListener);
}
-
+
/**
* Ensures the rectangle which displays rows from <code>minIndex</code> to <code>maxIndex</code> is visible.
*/
- private void makeRowsVisible(int minRow, int maxRow) {
- // Compute the rectangle that includes a row
+ private void makeRowsVisible(int minRow, int maxRow) {
+ // Compute the rectangle that includes a row
Rectangle includingRectangle = getCellRect(minRow, 0, true);
if (minRow != maxRow) {
includingRectangle = includingRectangle.
- union(getCellRect(maxRow, 0, true));
+ union(getCellRect(maxRow, 0, true));
}
if (getAutoResizeMode() == AUTO_RESIZE_OFF) {
int lastColumn = getColumnCount() - 1;
@@ -260,7 +266,7 @@ public class FurnitureLibraryTable extends JTable implements View {
union(getCellRect(minRow, lastColumn, true));
if (minRow != maxRow) {
includingRectangle = includingRectangle.
- union(getCellRect(maxRow, lastColumn, true));
+ union(getCellRect(maxRow, lastColumn, true));
}
}
scrollRectToVisible(includingRectangle);
@@ -273,7 +279,7 @@ public class FurnitureLibraryTable extends JTable implements View {
final FurnitureLanguageController controller) {
PropertyChangeListener listener = new PropertyChangeListener() {
private boolean sorting = false;
-
+
public void propertyChange(PropertyChangeEvent ev) {
if (!sorting) {
// Postpone update in case of multiple localized data is set
@@ -311,7 +317,7 @@ public class FurnitureLibraryTable extends JTable implements View {
preferredWidth = Math.max(preferredWidth, column.getHeaderRenderer().getTableCellRendererComponent(
this, column.getHeaderValue(), false, false, -1, columnIndex).getPreferredSize().width);
for (int rowIndex = 0, m = tableModel.getRowCount(); rowIndex < m; rowIndex++) {
- preferredWidth = Math.max(preferredWidth,
+ preferredWidth = Math.max(preferredWidth,
column.getCellRenderer().getTableCellRendererComponent(
this, tableModel.getValueAt(rowIndex, modelColumnIndex), false, false, -1, columnIndex).
getPreferredSize().width);
@@ -325,7 +331,7 @@ public class FurnitureLibraryTable extends JTable implements View {
* Returns the tool tip displayed by this tree.
*/
@Override
- public JToolTip createToolTip() {
+ public JToolTip createToolTip() {
if (this.toolTip.isTipTextComplete()) {
// Use toolTip object only for its text returned in getToolTipText
return super.createToolTip();
@@ -341,7 +347,7 @@ public class FurnitureLibraryTable extends JTable implements View {
@Override
public String getToolTipText(MouseEvent ev) {
int column = columnAtPoint(ev.getPoint());
- if (column != -1
+ if (column != -1
&& FurnitureLibrary.FURNITURE_ICON_PROPERTY.equals(getColumnModel().getColumn(column).getIdentifier())) {
int row = rowAtPoint(ev.getPoint());
if (row != -1) {
@@ -351,23 +357,23 @@ public class FurnitureLibraryTable extends JTable implements View {
}
return null;
}
-
+
@Override
public Dimension getPreferredScrollableViewportSize() {
return new Dimension(getPreferredSize().width, 400);
}
-
-
+
+
/**
* Model used by furniture table.
*/
private static class FurnitureLibraryTableModel extends AbstractTableModel {
private final FurnitureLibrary furnitureLibrary;
- private final FurnitureLanguageController controller;
+ private final FurnitureLanguageController controller;
private List<CatalogPieceOfFurniture> sortedFurniture;
private String sortProperty;
private boolean descendingOrder;
-
+
public FurnitureLibraryTableModel(FurnitureLibrary furnitureLibrary,
FurnitureLanguageController controller) {
this.furnitureLibrary = furnitureLibrary;
@@ -398,51 +404,51 @@ public class FurnitureLibraryTable extends JTable implements View {
break;
}
}
-
+
/**
* Returns the index of an added <code>piece</code> in furniture table, with a default index
* of <code>pieceIndex</code> if furniture library isn't sorting.
* If <code>piece</code> isn't added to furniture table, the returned value is
* equals to the insertion index where piece should be added.
*/
- private int getPieceOfFurnitureInsertionIndex(CatalogPieceOfFurniture piece,
- FurnitureLibrary furnitureLibrary,
+ private int getPieceOfFurnitureInsertionIndex(CatalogPieceOfFurniture piece,
+ FurnitureLibrary furnitureLibrary,
int pieceIndex) {
if (sortProperty == null) {
return pieceIndex;
- }
- // Default case when piece is included and furniture is sorting
+ }
+ // Default case when piece is included and furniture is sorting
int sortedIndex = Collections.binarySearch(sortedFurniture, piece, getFurnitureComparator(sortProperty));
if (sortedIndex >= 0) {
return sortedIndex;
} else {
return -(sortedIndex + 1);
- }
+ }
}
-
+
/**
* Returns the index of an existing <code>piece</code> in furniture table, with a default index
* of <code>pieceIndex</code> if furniture isn't sorting.
*/
- private int getPieceOfFurnitureDeletionIndex(CatalogPieceOfFurniture piece,
- FurnitureLibrary furnitureLibrary,
+ private int getPieceOfFurnitureDeletionIndex(CatalogPieceOfFurniture piece,
+ FurnitureLibrary furnitureLibrary,
int pieceIndex) {
if (sortProperty == null) {
return pieceIndex;
- }
- return getPieceOfFurnitureIndex(piece);
+ }
+ return getPieceOfFurnitureIndex(piece);
}
});
}
@Override
public String getColumnName(int columnIndex) {
- // Column name is set by TableColumn instances themselves
+ // Column name is set by TableColumn instances themselves
return null;
}
public int getColumnCount() {
- // Column count is set by TableColumnModel itself
+ // Column count is set by TableColumnModel itself
return 0;
}
@@ -456,7 +462,7 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns the index of <code>piece</code> in furniture table, or -1.
+ * Returns the index of <code>piece</code> in furniture table, or -1.
*/
public int getPieceOfFurnitureIndex(CatalogPieceOfFurniture searchedPiece) {
for (int i = 0, n = this.sortedFurniture.size(); i < n; i++) {
@@ -472,7 +478,7 @@ public class FurnitureLibraryTable extends JTable implements View {
* Sorts furniture.
*/
public void sortFurniture() {
- int previousRowCount = this.sortedFurniture != null
+ int previousRowCount = this.sortedFurniture != null
? this.sortedFurniture.size()
: 0;
List<CatalogPieceOfFurniture> libraryFurniture = this.furnitureLibrary.getFurniture();
@@ -480,9 +486,9 @@ public class FurnitureLibraryTable extends JTable implements View {
// Sort it if necessary
if (this.sortProperty != null) {
Comparator<CatalogPieceOfFurniture> furnitureComparator = getFurnitureComparator(this.sortProperty);
- Collections.sort(this.sortedFurniture, furnitureComparator);
+ Collections.sort(this.sortedFurniture, furnitureComparator);
}
-
+
if (previousRowCount != this.sortedFurniture.size()) {
fireTableDataChanged();
} else {
@@ -499,7 +505,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getId() == null) {
return -1;
} else if (piece2.getId() == null) {
- return 1;
+ return 1;
} else {
return collator.compare(piece1.getId(), piece2.getId());
}
@@ -526,7 +532,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String piece2Description = (String)furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece2, controller.getFurnitureLangauge(), propertyKey, piece2.getDescription());
if (piece2Description == null) {
- return 1;
+ return 1;
} else {
return collator.compare(piece1Description, piece2Description);
}
@@ -550,7 +556,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String [] piece2Tags = (String [])furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece2, controller.getFurnitureLangauge(), propertyKey, piece2.getTags());
if (piece2Tags == null) {
- return 1;
+ return 1;
} else {
return collator.compare(Arrays.toString(piece1Tags), Arrays.toString(piece2Tags));
}
@@ -568,7 +574,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String piece2Information = (String)furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece2, controller.getFurnitureLangauge(), propertyKey, piece2.getInformation());
if (piece2Information == null) {
- return 1;
+ return 1;
} else {
return collator.compare(piece1Information, piece2Information);
}
@@ -581,7 +587,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getCreationDate() == null) {
return -1;
} else if (piece2.getCreationDate() == null) {
- return 1;
+ return 1;
} else {
return piece1.getCreationDate().compareTo(piece2.getCreationDate());
}
@@ -593,7 +599,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getGrade() == null) {
return -1;
} else if (piece2.getGrade() == null) {
- return 1;
+ return 1;
} else {
return piece1.getGrade().compareTo(piece2.getGrade());
}
@@ -615,7 +621,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getPrice() == null) {
return -1;
} else if (piece2.getPrice() == null) {
- return 1;
+ return 1;
} else {
return piece1.getPrice().compareTo(piece2.getPrice());
}
@@ -627,7 +633,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getValueAddedTaxPercentage() == null) {
return -1;
} else if (piece2.getValueAddedTaxPercentage() == null) {
- return 1;
+ return 1;
} else {
return piece1.getValueAddedTaxPercentage().compareTo(piece2.getValueAddedTaxPercentage());
}
@@ -636,7 +642,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_WIDTH_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.getWidth() < piece2.getWidth()
+ return piece1.getWidth() < piece2.getWidth()
? -1
: (piece1.getWidth() == piece2.getWidth()
? 0 : 1);
@@ -645,7 +651,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_DEPTH_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.getDepth() < piece2.getDepth()
+ return piece1.getDepth() < piece2.getDepth()
? -1
: (piece1.getDepth() == piece2.getDepth()
? 0 : 1);
@@ -654,7 +660,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_HEIGHT_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.getHeight() < piece2.getHeight()
+ return piece1.getHeight() < piece2.getHeight()
? -1
: (piece1.getHeight() == piece2.getHeight()
? 0 : 1);
@@ -663,7 +669,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_MOVABLE_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.isMovable() == piece2.isMovable()
+ return piece1.isMovable() == piece2.isMovable()
? 0
: (piece1.isMovable()
? -1 : 1);
@@ -672,7 +678,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_DOOR_OR_WINDOW_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.isDoorOrWindow() == piece2.isDoorOrWindow()
+ return piece1.isDoorOrWindow() == piece2.isDoorOrWindow()
? 0
: (piece1.isDoorOrWindow()
? -1 : 1);
@@ -684,7 +690,7 @@ public class FurnitureLibraryTable extends JTable implements View {
if (piece1.getStaircaseCutOutShape() == null) {
return -1;
} else if (piece2.getStaircaseCutOutShape() == null) {
- return 1;
+ return 1;
} else {
return piece1.getStaircaseCutOutShape().compareTo(piece2.getStaircaseCutOutShape());
}
@@ -693,7 +699,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_ELEVATION_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.getElevation() < piece2.getElevation()
+ return piece1.getElevation() < piece2.getElevation()
? -1
: (piece1.getElevation() == piece2.getElevation()
? 0 : 1);
@@ -702,7 +708,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_RESIZABLE_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.isResizable() == piece2.isResizable()
+ return piece1.isResizable() == piece2.isResizable()
? 0
: (piece1.isResizable()
? -1 : 1);
@@ -711,7 +717,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_DEFORMABLE_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.isDeformable() == piece2.isDeformable()
+ return piece1.isDeformable() == piece2.isDeformable()
? 0
: (piece1.isDeformable()
? -1 : 1);
@@ -720,7 +726,7 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_TEXTURABLE_PROPERTY.equals(propertyKey)) {
furnitureComparator = new Comparator<CatalogPieceOfFurniture>() {
public int compare(CatalogPieceOfFurniture piece1, CatalogPieceOfFurniture piece2) {
- return piece1.isTexturable() == piece2.isTexturable()
+ return piece1.isTexturable() == piece2.isTexturable()
? 0
: (piece1.isTexturable()
? -1 : 1);
@@ -757,24 +763,24 @@ public class FurnitureLibraryTable extends JTable implements View {
this.sortProperty = sortProperty;
sortFurniture();
}
-
+
public boolean isDescendingOrder() {
return this.descendingOrder;
}
-
+
public void setDescendingOrder(boolean descendingOrder) {
this.descendingOrder = descendingOrder;
sortFurniture();
}
}
-
+
/**
* Column table model used by furniture library table.
*/
private static class FurnitureLibraryTableColumnModel extends DefaultTableColumnModel {
- public FurnitureLibraryTableColumnModel(FurnitureLibrary furnitureLibrary,
- FurnitureLibraryUserPreferences preferences,
+ public FurnitureLibraryTableColumnModel(FurnitureLibrary furnitureLibrary,
+ FurnitureLibraryUserPreferences preferences,
FurnitureLanguageController controller) {
createColumns(furnitureLibrary, preferences, controller);
addLanguageListener(preferences);
@@ -783,14 +789,14 @@ public class FurnitureLibraryTable extends JTable implements View {
/**
* Creates the list of available columns from furniture sortable properties.
*/
- private void createColumns(FurnitureLibrary furnitureLibrary,
- FurnitureLibraryUserPreferences preferences,
+ private void createColumns(FurnitureLibrary furnitureLibrary,
+ FurnitureLibraryUserPreferences preferences,
FurnitureLanguageController controller) {
// Create the list of custom columns
TableCellRenderer headerRenderer = getHeaderRenderer();
for (String columnProperty : preferences.getEditedProperties()) {
- if (!FurnitureLibrary.FURNITURE_MODEL_ROTATION_PROPERTY.equals(columnProperty)
- && !FurnitureLibrary.FURNITURE_MODEL_PROPERTY.equals(columnProperty)
+ if (!FurnitureLibrary.FURNITURE_MODEL_ROTATION_PROPERTY.equals(columnProperty)
+ && !FurnitureLibrary.FURNITURE_MODEL_PROPERTY.equals(columnProperty)
&& !FurnitureLibrary.FURNITURE_DOOR_OR_WINDOW_CUT_OUT_SHAPE_PROPERTY.equals(columnProperty)) {
TableColumn tableColumn = new TableColumn();
tableColumn.setIdentifier(columnProperty);
@@ -808,13 +814,13 @@ public class FurnitureLibraryTable extends JTable implements View {
* column names when preferred language changes.
*/
private void addLanguageListener(UserPreferences preferences) {
- preferences.addPropertyChangeListener(UserPreferences.Property.LANGUAGE,
+ preferences.addPropertyChangeListener(UserPreferences.Property.LANGUAGE,
new LanguageChangeListener(this));
}
/**
* Preferences property listener bound to this component with a weak reference to avoid
- * strong link between preferences and this component.
+ * strong link between preferences and this component.
*/
private static class LanguageChangeListener implements PropertyChangeListener {
private WeakReference<FurnitureLibraryTableColumnModel> furnitureTableColumnModel;
@@ -822,14 +828,14 @@ public class FurnitureLibraryTable extends JTable implements View {
public LanguageChangeListener(FurnitureLibraryTableColumnModel furnitureTable) {
this.furnitureTableColumnModel = new WeakReference<FurnitureLibraryTableColumnModel>(furnitureTable);
}
-
+
public void propertyChange(PropertyChangeEvent ev) {
// If furniture table column model was garbage collected, remove this listener from preferences
FurnitureLibraryTableColumnModel furnitureTableColumnModel = this.furnitureTableColumnModel.get();
UserPreferences preferences = (UserPreferences)ev.getSource();
if (furnitureTableColumnModel == null) {
preferences.removePropertyChangeListener(UserPreferences.Property.LANGUAGE, this);
- } else {
+ } else {
// Change column name and renderer from current locale
for (int i = 0; i < furnitureTableColumnModel.getColumnCount(); i++) {
TableColumn tableColumn = furnitureTableColumnModel.getColumn(i);
@@ -846,11 +852,11 @@ public class FurnitureLibraryTable extends JTable implements View {
}
}
}
-
+
/**
* Returns localized column names.
*/
- private String getColumnName(String propertyKey,
+ private String getColumnName(String propertyKey,
UserPreferences preferences) {
if (FurnitureLibrary.FURNITURE_ID_PROPERTY.equals(propertyKey)) {
return preferences.getLocalizedString(FurnitureLibraryTable.class, "idColumn");
@@ -906,7 +912,7 @@ public class FurnitureLibraryTable extends JTable implements View {
throw new IllegalArgumentException("Unknown key " + propertyKey);
}
}
-
+
/**
* Returns the preferred width of a column.
*/
@@ -953,13 +959,13 @@ public class FurnitureLibraryTable extends JTable implements View {
throw new IllegalArgumentException("Unknown key " + propertyKey);
}
}
-
+
/**
* Returns column renderers.
*/
- private TableCellRenderer getColumnRenderer(String propertyKey,
- FurnitureLibrary furnitureLibrary,
- UserPreferences preferences,
+ private TableCellRenderer getColumnRenderer(String propertyKey,
+ FurnitureLibrary furnitureLibrary,
+ UserPreferences preferences,
FurnitureLanguageController controller) {
if (FurnitureLibrary.FURNITURE_ID_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_NAME_PROPERTY.equals(propertyKey)
@@ -968,10 +974,10 @@ public class FurnitureLibraryTable extends JTable implements View {
|| FurnitureLibrary.FURNITURE_TAGS_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_CATEGORY_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_CREATOR_PROPERTY.equals(propertyKey)) {
- return getStringRenderer(propertyKey, furnitureLibrary, controller);
+ return getStringRenderer(propertyKey, furnitureLibrary, controller);
} else if (FurnitureLibrary.FURNITURE_ICON_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_PLAN_ICON_PROPERTY.equals(propertyKey)) {
- return getIconRenderer(propertyKey);
+ return getIconRenderer(propertyKey);
} else if (FurnitureLibrary.FURNITURE_CREATION_DATE_PROPERTY.equals(propertyKey)) {
return getCreationDateRenderer();
} else if (FurnitureLibrary.FURNITURE_GRADE_PROPERTY.equals(propertyKey)) {
@@ -979,9 +985,9 @@ public class FurnitureLibraryTable extends JTable implements View {
} else if (FurnitureLibrary.FURNITURE_MODEL_PROPERTY.equals(propertyKey)) {
return getButtonRenderer(propertyKey, preferences);
} else if (FurnitureLibrary.FURNITURE_PRICE_PROPERTY.equals(propertyKey)) {
- return getPriceRenderer(preferences);
+ return getPriceRenderer(preferences);
} else if (FurnitureLibrary.FURNITURE_VALUE_ADDED_TAX_PERCENTAGE_PROPERTY.equals(propertyKey)) {
- return getValueAddedTaxPercentageRenderer();
+ return getValueAddedTaxPercentageRenderer();
} else if (FurnitureLibrary.FURNITURE_WIDTH_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_DEPTH_PROPERTY.equals(propertyKey)
|| FurnitureLibrary.FURNITURE_HEIGHT_PROPERTY.equals(propertyKey)
@@ -1002,10 +1008,10 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays a string property of a piece of furniture.
+ * Returns a renderer that displays a string property of a piece of furniture.
*/
- private TableCellRenderer getStringRenderer(final String propertyKey,
- final FurnitureLibrary furnitureLibrary,
+ private TableCellRenderer getStringRenderer(final String propertyKey,
+ final FurnitureLibrary furnitureLibrary,
final FurnitureLanguageController controller) {
if (FurnitureLibrary.FURNITURE_ID_PROPERTY.equals(propertyKey)) {
return new DefaultTableCellRenderer() {
@@ -1013,7 +1019,7 @@ public class FurnitureLibraryTable extends JTable implements View {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
return super.getTableCellRendererComponent(
- table, ((CatalogPieceOfFurniture)value).getId(), isSelected, hasFocus, row, column);
+ table, ((CatalogPieceOfFurniture)value).getId(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_NAME_PROPERTY.equals(propertyKey)) {
@@ -1037,7 +1043,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String pieceDescription = (String)furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece, controller.getFurnitureLangauge(), propertyKey, piece.getDescription());
return super.getTableCellRendererComponent(
- table, pieceDescription, isSelected, hasFocus, row, column);
+ table, pieceDescription, isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_INFORMATION_PROPERTY.equals(propertyKey)) {
@@ -1049,7 +1055,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String pieceInformation = (String)furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece, controller.getFurnitureLangauge(), propertyKey, piece.getInformation());
return super.getTableCellRendererComponent(
- table, pieceInformation, isSelected, hasFocus, row, column);
+ table, pieceInformation, isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_TAGS_PROPERTY.equals(propertyKey)) {
@@ -1062,7 +1068,7 @@ public class FurnitureLibraryTable extends JTable implements View {
piece, controller.getFurnitureLangauge(), propertyKey, piece.getTags());
String tagsText = Arrays.toString(pieceTags);
return super.getTableCellRendererComponent(
- table, tagsText.substring(1, tagsText.length() - 1), isSelected, hasFocus, row, column);
+ table, tagsText.substring(1, tagsText.length() - 1), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_CATEGORY_PROPERTY.equals(propertyKey)) {
@@ -1074,7 +1080,7 @@ public class FurnitureLibraryTable extends JTable implements View {
String pieceCategory = (String)furnitureLibrary.getPieceOfFurnitureLocalizedData(
piece, controller.getFurnitureLangauge(), propertyKey, piece.getCategory().getName());
return super.getTableCellRendererComponent(
- table, pieceCategory, isSelected, hasFocus, row, column);
+ table, pieceCategory, isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_CREATOR_PROPERTY.equals(propertyKey)) {
@@ -1083,11 +1089,11 @@ public class FurnitureLibraryTable extends JTable implements View {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
return super.getTableCellRendererComponent(
- table, ((CatalogPieceOfFurniture)value).getCreator(), isSelected, hasFocus, row, column);
+ table, ((CatalogPieceOfFurniture)value).getCreator(), isSelected, hasFocus, row, column);
}
};
} else {
- throw new IllegalArgumentException(propertyKey + " column not a string column");
+ throw new IllegalArgumentException(propertyKey + " column not a string column");
}
}
@@ -1112,22 +1118,22 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays the icons of a piece of furniture.
+ * Returns a renderer that displays the icons of a piece of furniture.
*/
private TableCellRenderer getIconRenderer(final String propertyKey) {
- return new DefaultTableCellRenderer() {
+ return new DefaultTableCellRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
- CatalogPieceOfFurniture piece = (CatalogPieceOfFurniture)value;
+ CatalogPieceOfFurniture piece = (CatalogPieceOfFurniture)value;
JLabel label = (JLabel)super.getTableCellRendererComponent(
- table, "", isSelected, hasFocus, row, column);
+ table, "", isSelected, hasFocus, row, column);
Content iconContent;
if (FurnitureLibrary.FURNITURE_ICON_PROPERTY.equals(propertyKey)) {
- iconContent = piece.getIcon();
+ iconContent = piece.getIcon();
} else {
- iconContent = piece.getPlanIcon();
+ iconContent = piece.getPlanIcon();
}
if (iconContent != null) {
label.setIcon(IconManager.getInstance().getIcon(
@@ -1142,12 +1148,12 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays the creation date of a piece of furniture.
+ * Returns a renderer that displays the creation date of a piece of furniture.
*/
private TableCellRenderer getCreationDateRenderer() {
return new DefaultTableCellRenderer() {
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
value = ((CatalogPieceOfFurniture)value).getCreationDate();
if (value != null) {
@@ -1163,12 +1169,12 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays the grade of a piece of furniture.
+ * Returns a renderer that displays the grade of a piece of furniture.
*/
private TableCellRenderer getGradeRenderer() {
return new DefaultTableCellRenderer() {
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
value = ((CatalogPieceOfFurniture)value).getGrade();
if (value != null) {
@@ -1184,15 +1190,15 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that converts the displayed <code>property</code> of a piece of furniture
- * to inch in case preferences unit us equal to INCH.
+ * Returns a renderer that converts the displayed <code>property</code> of a piece of furniture
+ * to inch in case preferences unit us equal to INCH.
*/
private TableCellRenderer getSizeRenderer(String propertyKey,
final UserPreferences preferences) {
// Renderer super class used to display sizes
class SizeRenderer extends DefaultTableCellRenderer {
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
value = preferences.getLengthUnit().getFormat().format((Float)value);
setHorizontalAlignment(JLabel.RIGHT);
@@ -1200,40 +1206,40 @@ public class FurnitureLibraryTable extends JTable implements View {
table, value, isSelected, hasFocus, row, column);
}
};
-
+
if (FurnitureLibrary.FURNITURE_WIDTH_PROPERTY.equals(propertyKey)) {
return new SizeRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).getWidth(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_DEPTH_PROPERTY.equals(propertyKey)) {
return new SizeRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).getDepth(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_HEIGHT_PROPERTY.equals(propertyKey)) {
return new SizeRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).getHeight(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_ELEVATION_PROPERTY.equals(propertyKey)) {
return new SizeRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).getElevation(), isSelected, hasFocus, row, column);
}
};
@@ -1243,12 +1249,12 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays the price of a piece of furniture.
+ * Returns a renderer that displays the price of a piece of furniture.
*/
private TableCellRenderer getPriceRenderer(final UserPreferences preferences) {
return new DefaultTableCellRenderer() {
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
value = ((CatalogPieceOfFurniture)value).getPrice();
if (value != null) {
@@ -1272,13 +1278,13 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays the value added tax percentage property of a piece of furniture.
+ * Returns a renderer that displays the value added tax percentage property of a piece of furniture.
*/
private TableCellRenderer getValueAddedTaxPercentageRenderer() {
- return new DefaultTableCellRenderer() {
+ return new DefaultTableCellRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus,
+ public Component getTableCellRendererComponent(JTable table,
+ Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
BigDecimal valueAddedTaxPercentage = ((CatalogPieceOfFurniture)value).getValueAddedTaxPercentage();
if (valueAddedTaxPercentage != null) {
@@ -1296,15 +1302,15 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns a renderer that displays a property of a piece of furniture
- * with <code>JTable</code> default boolean renderer.
+ * Returns a renderer that displays a property of a piece of furniture
+ * with <code>JTable</code> default boolean renderer.
*/
private TableCellRenderer getBooleanRenderer(String propertyKey) {
// Renderer super class used to display booleans
class BooleanRenderer implements TableCellRenderer {
private TableCellRenderer booleanRenderer;
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (this.booleanRenderer == null) {
this.booleanRenderer = table.getDefaultRenderer(Boolean.class);
@@ -1313,58 +1319,58 @@ public class FurnitureLibraryTable extends JTable implements View {
table, value, isSelected, hasFocus, row, column);
}
};
-
+
if (FurnitureLibrary.FURNITURE_MOVABLE_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).isMovable(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_DOOR_OR_WINDOW_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).isDoorOrWindow(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_STAIRCASE_CUT_OUT_SHAPE_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).getStaircaseCutOutShape() != null, isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_RESIZABLE_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).isResizable(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_DEFORMABLE_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).isDeformable(), isSelected, hasFocus, row, column);
}
};
} else if (FurnitureLibrary.FURNITURE_TEXTURABLE_PROPERTY.equals(propertyKey)) {
return new BooleanRenderer() {
@Override
- public Component getTableCellRendererComponent(JTable table,
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return super.getTableCellRendererComponent(table,
+ return super.getTableCellRendererComponent(table,
((CatalogPieceOfFurniture)value).isTexturable(), isSelected, hasFocus, row, column);
}
};
@@ -1374,17 +1380,17 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns column header renderer that displays an ascending or a descending icon
+ * Returns column header renderer that displays an ascending or a descending icon
* when column is sorted, beside column name.
*/
private TableCellRenderer getHeaderRenderer() {
// Return a table renderer that displays the icon matching current sort
return new TableCellRenderer() {
- private TableCellRenderer headerRenderer;
+ private TableCellRenderer headerRenderer;
private ImageIcon ascendingSortIcon = new ImageIcon(getClass().getResource("resources/ascending.png"));
private ImageIcon descendingSortIcon = new ImageIcon(getClass().getResource("resources/descending.png"));
-
- public Component getTableCellRendererComponent(JTable table,
+
+ public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (this.headerRenderer == null) {
this.headerRenderer = table.getTableHeader().getDefaultRenderer();
@@ -1410,13 +1416,13 @@ public class FurnitureLibraryTable extends JTable implements View {
}
}
-
+
/**
* Table transfer handler.
*/
private class TableTransferHandler extends TransferHandler {
private final FurnitureLibraryController furnitureController;
-
+
/**
* Creates a handler able to receive furniture files.
*/
@@ -1430,7 +1436,7 @@ public class FurnitureLibraryTable extends JTable implements View {
}
/**
- * Returns <code>true</code> if flavors contains
+ * Returns <code>true</code> if flavors contains
* <code>DataFlavor.javaFileListFlavor</code> flavor.
*/
@Override
@@ -1448,12 +1454,12 @@ public class FurnitureLibraryTable extends JTable implements View {
if (canImport(destination, transferable.getTransferDataFlavors())) {
try {
List<File> files = (List<File>)transferable.getTransferData(DataFlavor.javaFileListFlavor);
- final List<String> importableModels = new ArrayList<String>();
+ final List<String> importableModels = new ArrayList<String>();
for (File file : files) {
if (!file.isDirectory()) {
String absolutePath = file.getAbsolutePath();
importableModels.add(absolutePath);
- }
+ }
}
EventQueue.invokeLater(new Runnable() {
public void run() {
=====================================
src/com/eteks/furniturelibraryeditor/swing/FurnitureLibraryUserPreferencesPanel.java
=====================================
@@ -67,7 +67,7 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
/**
* Creates and initializes components and their models.
*/
- private void createComponents(UserPreferences preferences,
+ private void createComponents(UserPreferences preferences,
final FurnitureLibraryUserPreferencesController controller) {
abstract class DocumentChangeListener implements DocumentListener {
public void insertUpdate(DocumentEvent ev) {
@@ -78,7 +78,7 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
changedUpdate(ev);
}
};
-
+
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR)) {
// Create default author label and its text field bound to DEFAULT_CREATOR controller property
this.defaultCreatorLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurnitureLibraryUserPreferencesPanel.class, "defaultCreatorLabel.text"));
@@ -95,7 +95,7 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
this.defaultCreatorTextField.getDocument().addDocumentListener(new DocumentChangeListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.DEFAULT_CREATOR, creatorChangeListener);
- String defaultCreator = defaultCreatorTextField.getText();
+ String defaultCreator = defaultCreatorTextField.getText();
if (defaultCreator == null || defaultCreator.trim().length() == 0) {
controller.setDefaultCreator(null);
} else {
@@ -105,19 +105,19 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
}
});
}
-
+
if (controller.isPropertyEditable(FurnitureLibraryUserPreferencesController.Property.OFFLINE_FURNITURE_LIBRARY)) {
// Create offline label and check box bound to controller OFFLINE_FURNITURE_LIBRARY property
this.offlineFurnitureLibraryLabel = new JLabel(preferences.getLocalizedString(
FurnitureLibraryUserPreferencesPanel.class, "offlineFurnitureLibraryLabel.text"));
- this.offlineFurnitureLibraryCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.offlineFurnitureLibraryCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurnitureLibraryUserPreferencesPanel.class, "offlineFurnitureLibraryCheckBox.text"), controller.isFurnitureLibraryOffline());
this.offlineFurnitureLibraryCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
controller.setFurnitureLibraryOffline(offlineFurnitureLibraryCheckBox.isSelected());
}
});
- controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.OFFLINE_FURNITURE_LIBRARY,
+ controller.addPropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.OFFLINE_FURNITURE_LIBRARY,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
boolean furnitureLibraryOffline = controller.isFurnitureLibraryOffline();
@@ -149,7 +149,7 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
this.furnitureResourcesLocalDirectoryTextField.getDocument().addDocumentListener(new DocumentChangeListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_LOCAL_DIRECTORY, localDirectoryChangeListener);
- String furnitureResourcesLocalDirectory = furnitureResourcesLocalDirectoryTextField.getText();
+ String furnitureResourcesLocalDirectory = furnitureResourcesLocalDirectoryTextField.getText();
if (furnitureResourcesLocalDirectory == null || furnitureResourcesLocalDirectory.trim().length() == 0) {
controller.setFurnitureResourcesLocalDirectory(null);
} else {
@@ -177,7 +177,7 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
this.furnitureResourcesRemoteUrlBaseTextField.getDocument().addDocumentListener(new DocumentChangeListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureLibraryUserPreferencesController.Property.FURNITURE_RESOURCES_REMOTE_URL_BASE, urlBaseChangeListener);
- String furnitureResourcesRemoteUrlBase = furnitureResourcesRemoteUrlBaseTextField.getText();
+ String furnitureResourcesRemoteUrlBase = furnitureResourcesRemoteUrlBaseTextField.getText();
if (furnitureResourcesRemoteUrlBase == null || furnitureResourcesRemoteUrlBase.trim().length() == 0) {
controller.setFurnitureResourcesRemoteURLBase(null);
} else {
@@ -187,8 +187,8 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
}
});
}
- }
-
+ }
+
/**
* Sets components mnemonics and label / component associations.
*/
@@ -215,46 +215,47 @@ public class FurnitureLibraryUserPreferencesPanel extends UserPreferencesPanel {
}
}
}
-
+
/**
- * Layouts panel components in panel with their labels.
+ * Layouts panel components in panel with their labels.
*/
private void layoutComponents() {
- int labelAlignment = OperatingSystem.isMacOSX()
+ int labelAlignment = OperatingSystem.isMacOSX()
? GridBagConstraints.LINE_END
: GridBagConstraints.LINE_START;
- Insets labelInsets = new Insets(0, 0, 5, 5);
- Insets componentInsets = new Insets(0, 0, 5, 0);
+ int gap = Math.round(5 * SwingTools.getResolutionScale());
+ Insets labelInsets = new Insets(0, 0, gap, gap);
+ Insets componentInsets = new Insets(0, 0, gap, 0);
if (this.defaultCreatorLabel != null) {
add(this.defaultCreatorLabel, new GridBagConstraints(
- 0, 100, 1, 1, 0, 0, labelAlignment,
+ 0, 100, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.defaultCreatorTextField, new GridBagConstraints(
- 1, 100, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 100, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.offlineFurnitureLibraryLabel != null) {
add(this.offlineFurnitureLibraryLabel, new GridBagConstraints(
- 0, 101, 1, 1, 0, 0, labelAlignment,
+ 0, 101, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.offlineFurnitureLibraryCheckBox, new GridBagConstraints(
- 1, 101, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 101, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
if (this.furnitureResourcesLocalDirectoryLabel != null) {
add(this.furnitureResourcesLocalDirectoryLabel, new GridBagConstraints(
- 0, 102, 1, 1, 0, 0, labelAlignment,
+ 0, 102, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.furnitureResourcesLocalDirectoryTextField, new GridBagConstraints(
- 1, 102, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 102, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.furnitureResourcesRemoteUrlBaseLabel != null) {
add(this.furnitureResourcesRemoteUrlBaseLabel, new GridBagConstraints(
- 0, 103, 1, 1, 0, 0, labelAlignment,
- GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
+ 0, 103, 1, 1, 0, 0, labelAlignment,
+ GridBagConstraints.NONE, new Insets(0, 0, 0, gap), 0, 0));
add(this.furnitureResourcesRemoteUrlBaseTextField, new GridBagConstraints(
- 1, 103, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 103, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
}
}
=====================================
src/com/eteks/furniturelibraryeditor/swing/FurniturePanel.java
=====================================
@@ -1,5 +1,5 @@
/*
- * FurniturePanel.java
+ * FurniturePanel.java
*
* Furniture Library Editor, Copyright (c) 2009 Emmanuel PUYBARET / eTeks <info at eteks.com>
*
@@ -164,7 +164,7 @@ public class FurniturePanel extends JPanel implements DialogView {
private String dialogTitle;
/**
- * Creates a panel that displays catalog furniture data according to the units
+ * Creates a panel that displays catalog furniture data according to the units
* set in <code>preferences</code>.
* @param preferences user preferences
* @param controller the controller of this panel
@@ -182,11 +182,11 @@ public class FurniturePanel extends JPanel implements DialogView {
/**
* Creates and initializes components and spinners model.
*/
- private void createComponents(final UserPreferences preferences,
+ private void createComponents(final UserPreferences preferences,
final FurnitureController controller) {
- // Get unit name matching current unit
+ // Get unit name matching current unit
String unitName = preferences.getLengthUnit().getName();
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.ID)) {
// Create id label and its text field bound to ID controller property
this.idLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurniturePanel.class, "idLabel.text"));
@@ -203,7 +203,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.idTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.ID, idChangeListener);
- String id = idTextField.getText();
+ String id = idTextField.getText();
if (id == null || id.trim().length() == 0) {
controller.setId(null);
} else {
@@ -211,17 +211,17 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.ID, idChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.NAME)) {
// Create name label and its text field bound to NAME controller property
this.nameLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurniturePanel.class, "nameLabel.text"));
@@ -238,7 +238,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.nameTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.NAME, nameChangeListener);
- String name = nameTextField.getText();
+ String name = nameTextField.getText();
if (name == null || name.trim().length() == 0) {
controller.setName(null);
} else {
@@ -246,17 +246,17 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.NAME, nameChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.DESCRIPTION)) {
// Create description label and its text field bound to DESCRIPTION controller property
this.descriptionLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurniturePanel.class, "descriptionLabel.text"));
@@ -273,7 +273,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.descriptionTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.DESCRIPTION, descriptionChangeListener);
- String description = descriptionTextField.getText();
+ String description = descriptionTextField.getText();
if (description == null || description.trim().length() == 0) {
controller.setDescription(null);
} else {
@@ -281,11 +281,11 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.DESCRIPTION, descriptionChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
@@ -308,7 +308,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.informationTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.INFORMATION, informationChangeListener);
- String information = informationTextField.getText();
+ String information = informationTextField.getText();
if (information == null || information.trim().length() == 0) {
controller.setInformation(null);
} else {
@@ -316,11 +316,11 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.INFORMATION, informationChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
@@ -353,7 +353,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.tagsTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.TAGS, tagsChangeListener);
- String tags = tagsTextField.getText();
+ String tags = tagsTextField.getText();
if (tags == null || tags.trim().length() == 0) {
controller.setTags(null);
} else {
@@ -361,11 +361,11 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.TAGS, tagsChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
@@ -388,7 +388,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.creatorTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.CREATOR, creatorChangeListener);
- String creator = creatorTextField.getText();
+ String creator = creatorTextField.getText();
if (creator == null || creator.trim().length() == 0) {
controller.setCreator(null);
} else {
@@ -396,20 +396,20 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.CREATOR, creatorChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.CATEGORY)) {
- this.categoryLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
- FurniturePanel.class, "categoryLabel.text"));
+ this.categoryLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ FurniturePanel.class, "categoryLabel.text"));
final List<FurnitureCategory> categories = controller.getAvailableCategories();
List<FurnitureCategory> categoriesList = new ArrayList<FurnitureCategory>(categories);
final boolean nullableComboBox = controller.getCategory() == null;
@@ -417,7 +417,7 @@ public class FurniturePanel extends JPanel implements DialogView {
categoriesList.add(0, null);
}
this.categoryComboBox = new JComboBox(categoriesList.toArray());
- this.categoryComboBox.setEditable(true);
+ this.categoryComboBox.setEditable(true);
final ComboBoxEditor defaultEditor = this.categoryComboBox.getEditor();
// Change editor to edit category name when the combo box isn't nullable
this.categoryComboBox.setEditor(new ComboBoxEditor() {
@@ -441,35 +441,35 @@ public class FurniturePanel extends JPanel implements DialogView {
if (categoryIndex >= 0) {
return categories.get(categoryIndex);
}
- // If no existing category was found, return a new one
+ // If no existing category was found, return a new one
return category;
}
}
-
+
public void setItem(Object value) {
if (value != null) {
defaultEditor.setItem(((FurnitureCategory)value).getName());
}
}
-
+
public void addActionListener(ActionListener l) {
defaultEditor.addActionListener(l);
}
-
+
public Component getEditorComponent() {
return defaultEditor.getEditorComponent();
}
-
+
public void removeActionListener(ActionListener l) {
defaultEditor.removeActionListener(l);
}
-
+
public void selectAll() {
defaultEditor.selectAll();
}
});
this.categoryComboBox.setRenderer(new DefaultListCellRenderer() {
- public Component getListCellRendererComponent(JList list, Object value, int index,
+ public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
if (value == null) {
value = " ";
@@ -499,7 +499,7 @@ public class FurniturePanel extends JPanel implements DialogView {
}
this.categoryComboBox.setMaximumRowCount(15);
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.CREATION_DATE)) {
// Create creation date label and spinner bound to CREATION_DATE controller property
this.creationDateLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences, FurniturePanel.class, "creationDateLabel.text"));
@@ -519,7 +519,7 @@ public class FurniturePanel extends JPanel implements DialogView {
JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(this.creationDateSpinner, datePattern);
this.creationDateSpinner.setEditor(dateEditor);
SwingTools.addAutoSelectionOnFocusGain(dateEditor.getTextField());
-
+
final PropertyChangeListener dateChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
if (controller.getCreationDate() != null) {
@@ -553,12 +553,12 @@ public class FurniturePanel extends JPanel implements DialogView {
};
creationDateSpinnerModel.addChangeListener(dateTimeChangeListener);
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.GRADE)) {
// Create grade label and spinner bound to GRADE controller property
- this.gradeLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.gradeLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "gradeLabel.text", unitName));
- final NullableSpinner.NullableSpinnerNumberModel gradeSpinnerModel =
+ final NullableSpinner.NullableSpinnerNumberModel gradeSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(0, 0f, 1f, 0.1f);
this.gradeSpinner = new AutoCommitSpinner(gradeSpinnerModel);
final PropertyChangeListener gradeChangeListener = new PropertyChangeListener() {
@@ -581,12 +581,12 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.PRICE)) {
// Create price label and its spinner bound to PRICE controller property
- this.priceLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.priceLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "priceLabel.text"));
- final NullableSpinner.NullableSpinnerNumberModel priceSpinnerModel =
+ final NullableSpinner.NullableSpinnerNumberModel priceSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(1, 0.00999f, 1000000f, 1f);
this.priceSpinner = new NullableSpinner(priceSpinnerModel);
priceSpinnerModel.setNullable(controller.getPrice() == null);
@@ -602,19 +602,19 @@ public class FurniturePanel extends JPanel implements DialogView {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.PRICE, priceChangeListener);
Object value = priceSpinnerModel.getValue();
- controller.setPrice(value != null
+ controller.setPrice(value != null
? new BigDecimal((Float)value).setScale(2, BigDecimal.ROUND_HALF_UP)
: (BigDecimal)value);
controller.addPropertyChangeListener(FurnitureController.Property.PRICE, priceChangeListener);
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE)) {
// Create VAT % label and its spinner bound to VALUE_ADDED_TAX_PERCENTAGE controller property
- this.valueAddedTaxPercentageLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.valueAddedTaxPercentageLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "valueAddedTaxPercentageLabel.text"));
- final NullableSpinner.NullableSpinnerNumberModel valueAddedTaxPercentageSpinnerModel =
+ final NullableSpinner.NullableSpinnerNumberModel valueAddedTaxPercentageSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(0, 0, 100f, 0.1f);
this.valueAddedTaxPercentageSpinner = new NullableSpinner(valueAddedTaxPercentageSpinnerModel);
valueAddedTaxPercentageSpinnerModel.setNullable(controller.getValueAddedTaxPercentage() == null);
@@ -634,21 +634,21 @@ public class FurniturePanel extends JPanel implements DialogView {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE, valueAddedTaxPercentageChangeListener);
Object value = valueAddedTaxPercentageSpinnerModel.getValue();
- controller.setValueAddedTaxPercentage(value != null
+ controller.setValueAddedTaxPercentage(value != null
? new BigDecimal((Float)value / 100).setScale(3, BigDecimal.ROUND_HALF_UP)
: (BigDecimal)value);
controller.addPropertyChangeListener(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE, valueAddedTaxPercentageChangeListener);
}
});
}
-
+
final float minimumLength = preferences.getLengthUnit().getMinimumLength();
final float maximumLength = preferences.getLengthUnit().getMaximumLength();
if (this.controller.isPropertyEditable(FurnitureController.Property.WIDTH)) {
// Create width label and its spinner bound to WIDTH controller property
- this.widthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.widthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "widthLabel.text", unitName));
- final NullableSpinner.NullableSpinnerLengthModel widthSpinnerModel =
+ final NullableSpinner.NullableSpinnerLengthModel widthSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, maximumLength);
this.widthSpinner = new NullableSpinner(widthSpinnerModel);
final PropertyChangeListener widthChangeListener = new PropertyChangeListener() {
@@ -674,12 +674,12 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.DEPTH)) {
// Create depth label and its spinner bound to DEPTH controller property
- this.depthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.depthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "depthLabel.text", unitName));
- final NullableSpinner.NullableSpinnerLengthModel depthSpinnerModel =
+ final NullableSpinner.NullableSpinnerLengthModel depthSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, maximumLength);
this.depthSpinner = new NullableSpinner(depthSpinnerModel);
final PropertyChangeListener depthChangeListener = new PropertyChangeListener() {
@@ -705,12 +705,12 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.HEIGHT)) {
// Create height label and its spinner bound to HEIGHT controller property
- this.heightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.heightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "heightLabel.text", unitName));
- final NullableSpinner.NullableSpinnerLengthModel heightSpinnerModel =
+ final NullableSpinner.NullableSpinnerLengthModel heightSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, maximumLength);
this.heightSpinner = new NullableSpinner(heightSpinnerModel);
final PropertyChangeListener heightChangeListener = new PropertyChangeListener() {
@@ -736,9 +736,9 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.PROPORTIONAL)) {
- this.keepProportionsCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.keepProportionsCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "keepProportionsCheckBox.text"), controller.isProportional());
this.keepProportionsCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
@@ -752,7 +752,7 @@ public class FurniturePanel extends JPanel implements DialogView {
keepProportionsCheckBox.setSelected(controller.isProportional());
}
});
-
+
this.enlargeTenTimesButton = new JButton(new ResourceAction(preferences, FurniturePanel.class, "ENLARGE_TEN_TIMES", true) {
@Override
public void actionPerformed(ActionEvent ev) {
@@ -772,12 +772,12 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.ELEVATION)) {
// Create elevation label and its spinner bound to ELEVATION controller property
- this.elevationLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
+ this.elevationLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "elevationLabel.text", unitName));
- final NullableSpinner.NullableSpinnerLengthModel elevationSpinnerModel =
+ final NullableSpinner.NullableSpinnerLengthModel elevationSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, 0f, preferences.getLengthUnit().getMaximumElevation());
this.elevationSpinner = new NullableSpinner(elevationSpinnerModel);
elevationSpinnerModel.setNullable(controller.getElevation() == null);
@@ -788,14 +788,14 @@ public class FurniturePanel extends JPanel implements DialogView {
elevationSpinnerModel.setLength((Float)ev.getNewValue());
}
};
- controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
+ controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
elevationChangeListener);
elevationSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
- controller.removePropertyChangeListener(FurnitureController.Property.ELEVATION,
+ controller.removePropertyChangeListener(FurnitureController.Property.ELEVATION,
elevationChangeListener);
controller.setElevation(elevationSpinnerModel.getLength());
- controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
+ controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
elevationChangeListener);
}
});
@@ -803,7 +803,7 @@ public class FurniturePanel extends JPanel implements DialogView {
if (this.controller.isPropertyEditable(FurnitureController.Property.MOVABLE)) {
// Create movable check box bound to MOVABLE controller property
- this.movableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.movableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "movableCheckBox.text"));
this.movableCheckBox.setNullable(controller.getMovable() == null);
this.movableCheckBox.setValue(controller.getMovable());
@@ -822,10 +822,10 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.DOOR_OR_WINDOW)) {
// Create doorOrWindow check box bound to DOOR_OR_WINDOW controller property
- this.doorOrWindowCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.doorOrWindowCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "doorOrWindowCheckBox.text"));
this.doorOrWindowCheckBox.setNullable(controller.getDoorOrWindow() == null);
this.doorOrWindowCheckBox.setValue(controller.getDoorOrWindow());
@@ -856,7 +856,7 @@ public class FurniturePanel extends JPanel implements DialogView {
if (this.controller.isPropertyEditable(FurnitureController.Property.DOOR_OR_WINDOW_CUT_OUT_SHAPE)) {
// Create cut out shape label and text field bound to DOOR_OR_WINDOW_CUT_OUT_SHAPE controller property
- this.doorOrWindowCustomizedCutOutShapeCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.doorOrWindowCustomizedCutOutShapeCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "doorOrWindowCustomizedCutOutShapeCheckBox.text"));
this.doorOrWindowCustomizedCutOutShapeCheckBox.setEnabled(Boolean.TRUE.equals(controller.getDoorOrWindow()));
this.doorOrWindowCustomizedCutOutShapeCheckBox.setSelected(controller.getDoorOrWindowCutOutShape() != null);
@@ -890,7 +890,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.doorOrWindowCustomizedCutOutShapeTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.DOOR_OR_WINDOW_CUT_OUT_SHAPE, customizedCutOutShapeChangeListener);
- String customizedCutOutShape = doorOrWindowCustomizedCutOutShapeTextField.getText();
+ String customizedCutOutShape = doorOrWindowCustomizedCutOutShapeTextField.getText();
if (customizedCutOutShape == null || customizedCutOutShape.trim().length() == 0) {
controller.setDoorOrWindowCutOutShape(null);
} else {
@@ -908,21 +908,21 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.DOOR_OR_WINDOW_CUT_OUT_SHAPE, customizedCutOutShapeChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
});
}
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.STAIRCASE_CUT_OUT_SHAPE)) {
// Create staircase check box and text field bound to STAIRCASE_CUT_OUT_SHAPE controller property
- this.staircaseCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.staircaseCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "staircaseCheckBox.text"));
this.staircaseCheckBox.setNullable(controller.getStaircase() == null);
this.staircaseCheckBox.setValue(controller.getStaircase());
@@ -958,7 +958,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.staircaseCutOutShapeTextField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.STAIRCASE_CUT_OUT_SHAPE, staircaseCutOutShapeChangeListener);
- String staircaseCutOutShape = staircaseCutOutShapeTextField.getText();
+ String staircaseCutOutShape = staircaseCutOutShapeTextField.getText();
if (staircaseCutOutShape == null || staircaseCutOutShape.trim().length() == 0) {
controller.setStaircaseCutOutShape(null);
} else {
@@ -976,20 +976,20 @@ public class FurniturePanel extends JPanel implements DialogView {
}
controller.addPropertyChangeListener(FurnitureController.Property.STAIRCASE_CUT_OUT_SHAPE, staircaseCutOutShapeChangeListener);
}
-
+
public void insertUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
-
+
public void removeUpdate(DocumentEvent ev) {
changedUpdate(ev);
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.BACK_FACE_SHOWN)) {
// Create back face shown check box bound to BACK_FACE_SHOWN controller property
- this.backFaceShownCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.backFaceShownCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "backFaceShownCheckBox.text"));
this.backFaceShownCheckBox.setNullable(controller.getBackFaceShown() == null);
this.backFaceShownCheckBox.setValue(controller.getBackFaceShown());
@@ -1009,10 +1009,10 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.RESIZABLE)) {
// Create resizable check box bound to RESIZABLE controller property
- this.resizableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.resizableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "resizableCheckBox.text"));
this.resizableCheckBox.setNullable(controller.getResizable() == null);
this.resizableCheckBox.setValue(controller.getResizable());
@@ -1031,10 +1031,10 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.DEFORMABLE)) {
// Create deformable check box bound to DEFORMABLE controller property
- this.deformableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.deformableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "deformableCheckBox.text"));
this.deformableCheckBox.setNullable(controller.getDeformable() == null);
this.deformableCheckBox.setValue(controller.getDeformable());
@@ -1053,10 +1053,10 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.TEXTURABLE)) {
// Create texturable check box bound to TEXTURABLE controller property
- this.texturableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
+ this.texturableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "texturableCheckBox.text"));
this.texturableCheckBox.setNullable(controller.getTexturable() == null);
this.texturableCheckBox.setValue(controller.getTexturable());
@@ -1075,7 +1075,7 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
if (this.controller.isPropertyEditable(FurnitureController.Property.ICON)) {
this.iconComponent = new IconPreviewComponent(controller, preferences);
this.turnLeftButton = new JButton(new ResourceAction(preferences, FurniturePanel.class, "TURN_LEFT", true) {
@@ -1122,7 +1122,7 @@ public class FurniturePanel extends JPanel implements DialogView {
if (this.controller.isPropertyEditable(FurnitureController.Property.MODEL)) {
if (this.iconComponent != null) {
- controller.addPropertyChangeListener(FurnitureController.Property.MODEL,
+ controller.addPropertyChangeListener(FurnitureController.Property.MODEL,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
resetIcon(true);
@@ -1134,7 +1134,7 @@ public class FurniturePanel extends JPanel implements DialogView {
public boolean canImport(JComponent comp, DataFlavor [] flavors) {
return Arrays.asList(flavors).contains(DataFlavor.javaFileListFlavor);
}
-
+
@Override
public boolean importData(JComponent comp, Transferable transferedFiles) {
boolean success = false;
@@ -1161,7 +1161,7 @@ public class FurniturePanel extends JPanel implements DialogView {
if (!success) {
EventQueue.invokeLater(new Runnable() {
public void run() {
- JOptionPane.showMessageDialog(SwingUtilities.getRootPane(FurniturePanel.this),
+ JOptionPane.showMessageDialog(SwingUtilities.getRootPane(FurniturePanel.this),
preferences.getLocalizedString(FurniturePanel.class, "modelError"),
preferences.getLocalizedString(FurniturePanel.class, "errorTitle"),
JOptionPane.ERROR_MESSAGE);
@@ -1173,12 +1173,12 @@ public class FurniturePanel extends JPanel implements DialogView {
});
this.iconComponent.setBorder(SwingTools.getDropableComponentBorder());
}
-
+
this.changeModelButton = new JButton(new ResourceAction(preferences, FurniturePanel.class, "CHANGE_MODEL", true) {
@Override
public void actionPerformed(ActionEvent ev) {
- String modelName = controller.getContentManager().showOpenDialog(FurniturePanel.this,
- preferences.getLocalizedString(FurniturePanel.class, "modelChoiceDialog.title"),
+ String modelName = controller.getContentManager().showOpenDialog(FurniturePanel.this,
+ preferences.getLocalizedString(FurniturePanel.class, "modelChoiceDialog.title"),
ContentManager.ContentType.MODEL);
if (modelName != null) {
controller.setModel(modelName);
@@ -1189,7 +1189,7 @@ public class FurniturePanel extends JPanel implements DialogView {
this.dialogTitle = preferences.getLocalizedString(FurniturePanel.class, "homeFurniture.title");
}
-
+
/**
* Returns the transformation matching current model rotation.
*/
@@ -1202,7 +1202,7 @@ public class FurniturePanel extends JPanel implements DialogView {
transform.setRotation(modelRotationMatrix);
return transform;
}
-
+
/**
* Updates model rotation from the values of <code>transform</code>.
*/
@@ -1219,7 +1219,7 @@ public class FurniturePanel extends JPanel implements DialogView {
}
/**
- * Resets the model icon.
+ * Resets the model icon.
*/
private void resetIcon(boolean resetView) {
if (this.controller.isPropertyEditable(FurnitureController.Property.ICON)) {
@@ -1352,34 +1352,35 @@ public class FurniturePanel extends JPanel implements DialogView {
}
}
}
-
+
/**
- * Layouts panel components in panel with their labels.
+ * Layouts panel components in panel with their labels.
*/
private void layoutComponents() {
- int labelAlignment = OperatingSystem.isMacOSX()
+ int labelAlignment = OperatingSystem.isMacOSX()
? GridBagConstraints.LINE_END
: GridBagConstraints.LINE_START;
- Insets labelInsets = new Insets(0, 0, 5, 5);
- Insets componentInsets = new Insets(0, 0, 5, 0);
+ int gap = Math.round(5 * SwingTools.getResolutionScale());
+ Insets labelInsets = new Insets(0, 0, gap, gap);
+ Insets componentInsets = new Insets(0, 0, gap, 0);
if (this.controller.isPropertyEditable(FurnitureController.Property.ICON)) {
JPanel iconPanel = new JPanel(new GridBagLayout());
- // Add dummy labels with a vertical weight of 1 at top and bottom of iconPanel
+ // Add dummy labels with a vertical weight of 1 at top and bottom of iconPanel
// to keep iconComponent and rotationButtonsPanel in the middle
// when grid bag fill constraint is BOTH for iconPanel.
// If this constraint is set to HORIZONTAL only, iconPanel location may be lower
- // and may not be the first panel treated by the focus traversal algorithm
+ // and may not be the first panel treated by the focus traversal algorithm
iconPanel.add(new JLabel(), new GridBagConstraints(
- 0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER,
+ 0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
if (this.controller.isPropertyEditable(FurnitureController.Property.MODEL)) {
iconPanel.add(this.changeModelButton, new GridBagConstraints(
- 0, 1, 1, 1, 0, 0, GridBagConstraints.CENTER,
- GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
+ 0, 1, 1, 1, 0, 0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(0, 0, gap, 0), 0, 0));
}
iconPanel.add(this.iconComponent, new GridBagConstraints(
- 0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
- GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
+ 0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
+ GridBagConstraints.NONE, new Insets(0, 0, gap, 0), 0, 0));
if (this.controller.isPropertyEditable(FurnitureController.Property.MODEL_ROTATION)) {
JPanel rotationButtonsPanel = new JPanel(new GridBagLayout()) {
@Override
@@ -1388,147 +1389,147 @@ public class FurniturePanel extends JPanel implements DialogView {
}
};
rotationButtonsPanel.add(this.turnUpButton, new GridBagConstraints(
- 1, 0, 1, 1, 0, 0, GridBagConstraints.SOUTH,
- GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));
+ 1, 0, 1, 1, 0, 0, GridBagConstraints.SOUTH,
+ GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));
rotationButtonsPanel.add(this.turnLeftButton, new GridBagConstraints(
- 0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
+ 0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 2, 2), 0, 0));
rotationButtonsPanel.add(this.turnRightButton, new GridBagConstraints(
- 2, 1, 1, 1, 1, 0, GridBagConstraints.WEST,
+ 2, 1, 1, 1, 1, 0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 2, 2, 0), 0, 0));
rotationButtonsPanel.add(this.turnDownButton, new GridBagConstraints(
- 1, 2, 1, 1, 0, 0, GridBagConstraints.NORTH,
+ 1, 2, 1, 1, 0, 0, GridBagConstraints.NORTH,
GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));
iconPanel.add(rotationButtonsPanel, new GridBagConstraints(
- 0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
+ 0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
iconPanel.add(new JLabel(), new GridBagConstraints(
- 0, 4, 1, 1, 0, 1, GridBagConstraints.CENTER,
+ 0, 4, 1, 1, 0, 1, GridBagConstraints.CENTER,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
add(iconPanel, new GridBagConstraints(
- 0, 0, 1, 16, 0, 0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 15), 0, 0));
+ 0, 0, 1, 16, 0, 0, GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH, new Insets(0, 0, 0, 3 * gap), 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.ID)) {
add(this.idLabel, new GridBagConstraints(
- 1, 0, 1, 1, 0, 0, labelAlignment,
+ 1, 0, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.idTextField, new GridBagConstraints(
- 2, 0, 3, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 0, 3, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.NAME)) {
add(this.nameLabel, new GridBagConstraints(
- 1, 1, 1, 1, 0, 0, labelAlignment,
+ 1, 1, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.nameTextField, new GridBagConstraints(
- 2, 1, 3, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 1, 3, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.DESCRIPTION)) {
add(this.descriptionLabel, new GridBagConstraints(
- 1, 2, 1, 1, 0, 0, labelAlignment,
+ 1, 2, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.descriptionTextField, new GridBagConstraints(
- 2, 2, 3, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 2, 3, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.INFORMATION)) {
add(this.informationLabel, new GridBagConstraints(
- 1, 3, 1, 1, 0, 0, labelAlignment,
+ 1, 3, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.informationTextField, new GridBagConstraints(
- 2, 3, 3, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 3, 3, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.TAGS)) {
add(this.tagsLabel, new GridBagConstraints(
- 1, 4, 1, 1, 0, 0, labelAlignment,
+ 1, 4, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.tagsTextField, new GridBagConstraints(
- 2, 4, 3, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 4, 3, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.CREATOR)) {
add(this.creatorLabel, new GridBagConstraints(
- 1, 5, 1, 1, 0, 0, labelAlignment,
+ 1, 5, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.creatorTextField, new GridBagConstraints(
- 2, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), 0, 0));
+ 2, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, gap, 2 * gap), 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.CATEGORY)) {
add(this.categoryLabel, new GridBagConstraints(
- 3, 5, 1, 1, 0, 0, labelAlignment,
+ 3, 5, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.categoryComboBox, new GridBagConstraints(
- 4, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.CREATION_DATE)) {
add(this.creationDateLabel, new GridBagConstraints(
- 1, 6, 1, 1, 0, 0, labelAlignment,
+ 1, 6, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.creationDateSpinner, new GridBagConstraints(
- 2, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), 0, 0));
+ 2, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, gap, 2 * gap), 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.GRADE)) {
add(this.gradeLabel, new GridBagConstraints(
- 3, 6, 1, 1, 0, 0, labelAlignment,
+ 3, 6, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.gradeSpinner, new GridBagConstraints(
- 4, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.PRICE)) {
add(this.priceLabel, new GridBagConstraints(
- 1, 7, 1, 1, 0, 0, labelAlignment,
+ 1, 7, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.priceSpinner, new GridBagConstraints(
- 2, 7, 1, 1, 0, 0, GridBagConstraints.LINE_START,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
+ 2, 7, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, gap, 2 * gap), -10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE)) {
add(this.valueAddedTaxPercentageLabel, new GridBagConstraints(
- 3, 7, 1, 1, 0, 0, labelAlignment,
+ 3, 7, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.valueAddedTaxPercentageSpinner, new GridBagConstraints(
- 4, 7, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 7, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.WIDTH)) {
add(this.widthLabel, new GridBagConstraints(
- 1, 8, 1, 1, 0, 0, labelAlignment,
+ 1, 8, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.widthSpinner, new GridBagConstraints(
- 2, 8, 1, 1, 0, 0, GridBagConstraints.LINE_START,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
+ 2, 8, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, gap, 2 * gap), -10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.DEPTH)) {
add(this.depthLabel, new GridBagConstraints(
- 3, 8, 1, 1, 0, 0, labelAlignment,
+ 3, 8, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.depthSpinner, new GridBagConstraints(
- 4, 8, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 8, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, -10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.HEIGHT)) {
add(this.heightLabel, new GridBagConstraints(
- 1, 9, 1, 1, 0, 0, labelAlignment,
+ 1, 9, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.heightSpinner, new GridBagConstraints(
- 2, 9, 1, 1, 0, 0, GridBagConstraints.LINE_START,
- GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
+ 2, 9, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ GridBagConstraints.HORIZONTAL, new Insets(0, 0, gap, 2 * gap), -10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.ELEVATION)) {
add(this.elevationLabel, new GridBagConstraints(
- 3, 9, 1, 1, 0, 0, labelAlignment,
+ 3, 9, 1, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.elevationSpinner, new GridBagConstraints(
- 4, 9, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 9, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, -10, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.PROPORTIONAL)) {
@@ -1537,69 +1538,69 @@ public class FurniturePanel extends JPanel implements DialogView {
multiplySizePanel.add(this.reduceTenTimesButton);
multiplySizePanel.add(this.enlargeInchTimesButton);
add(multiplySizePanel, new GridBagConstraints(
- 1, 10, 3, 1, 0, 0, GridBagConstraints.CENTER,
+ 1, 10, 3, 1, 0, 0, GridBagConstraints.CENTER,
GridBagConstraints.NONE, componentInsets, 0, 0));
add(this.keepProportionsCheckBox, new GridBagConstraints(
- 4, 10, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 10, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.BACK_FACE_SHOWN)) {
add(this.backFaceShownCheckBox, new GridBagConstraints(
- 1, 11, 2, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 11, 2, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.DOOR_OR_WINDOW)) {
add(this.doorOrWindowCheckBox, new GridBagConstraints(
- 1, 12, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 12, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
if (this.controller.isPropertyEditable(FurnitureController.Property.DOOR_OR_WINDOW_CUT_OUT_SHAPE)) {
add(this.doorOrWindowCustomizedCutOutShapeCheckBox, new GridBagConstraints(
- 2, 12, 2, 1, 0, 0, labelAlignment,
- GridBagConstraints.NONE, OperatingSystem.isMacOSX() ? new Insets(0, 0, 5, 0) : labelInsets, 0, 0));
+ 2, 12, 2, 1, 0, 0, labelAlignment,
+ GridBagConstraints.NONE, OperatingSystem.isMacOSX() ? new Insets(0, 0, gap, 0) : labelInsets, 0, 0));
add(this.doorOrWindowCustomizedCutOutShapeTextField, new GridBagConstraints(
- 4, 12, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 12, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
}
if (this.controller.isPropertyEditable(FurnitureController.Property.STAIRCASE_CUT_OUT_SHAPE)) {
add(this.staircaseCheckBox, new GridBagConstraints(
- 1, 13, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 13, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
add(this.staircaseCutOutShapeLabel, new GridBagConstraints(
- 2, 13, 2, 1, 0, 0, labelAlignment,
+ 2, 13, 2, 1, 0, 0, labelAlignment,
GridBagConstraints.NONE, labelInsets, 0, 0));
add(this.staircaseCutOutShapeTextField, new GridBagConstraints(
- 4, 13, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 13, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.MOVABLE)) {
add(this.movableCheckBox, new GridBagConstraints(
- 1, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 1, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.RESIZABLE)) {
add(this.resizableCheckBox, new GridBagConstraints(
- 2, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 2, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.DEFORMABLE)) {
add(this.deformableCheckBox, new GridBagConstraints(
- 3, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 3, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
if (this.controller.isPropertyEditable(FurnitureController.Property.TEXTURABLE)) {
add(this.texturableCheckBox, new GridBagConstraints(
- 4, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
+ 4, 14, 1, 1, 0, 0, GridBagConstraints.LINE_START,
GridBagConstraints.NONE, componentInsets, 0, 0));
}
}
/**
- * Displays this panel in a modal dialog box.
+ * Displays this panel in a modal dialog box.
*/
public void displayView(View parentView) {
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
- if (SwingTools.showConfirmDialog((JComponent)parentView,
+ if (SwingTools.showConfirmDialog((JComponent)parentView,
this, this.dialogTitle, this.nameTextField) == JOptionPane.OK_OPTION) {
if (this.controller.getBackFaceShown() != null
&& this.controller.getBackFaceShown()) {
@@ -1609,12 +1610,12 @@ public class FurniturePanel extends JPanel implements DialogView {
rootPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// Generate a modified model with back face (modifying the model is required because this information isn't stored in a SH3F file)
HomePieceOfFurniture3D piece3D = new HomePieceOfFurniture3D(new HomePieceOfFurniture(
- new CatalogPieceOfFurniture(this.controller.getName(), null,
+ new CatalogPieceOfFurniture(this.controller.getName(), null,
this.controller.getModel(), this.controller.getWidth(), this.controller.getDepth(), this.controller.getHeight(),
- 0, false, null, null, this.controller.getBackFaceShown(), 0, false)), null, true, true);
+ 0, false, null, null, this.controller.getBackFaceShown(), 0, false)), null, true, true);
this.controller.setModel(ImportFurnitureTaskPanel.copyToTemporaryOBJContent(piece3D, this.controller.getModel()));
} catch (IOException e) {
- JOptionPane.showMessageDialog(rootPane,
+ JOptionPane.showMessageDialog(rootPane,
preferences.getLocalizedString(FurniturePanel.class, "backFaceShownError"),
preferences.getLocalizedString(FurniturePanel.class, "errorTitle"),
JOptionPane.ERROR_MESSAGE);
@@ -1630,15 +1631,15 @@ public class FurniturePanel extends JPanel implements DialogView {
}
/**
- * Preview component for model icon.
+ * Preview component for model icon.
*/
private static class IconPreviewComponent extends ModelPreviewComponent {
private static final int PREFERRED_SIZE = 128;
-
+
private float defaultViewYaw;
private float defaultViewPitch;
private float defaultViewScale;
-
+
public IconPreviewComponent(final FurnitureController controller,
final UserPreferences preferences) {
super(true);
@@ -1649,12 +1650,12 @@ public class FurniturePanel extends JPanel implements DialogView {
addBackFaceShownListener(controller);
setBackground(UIManager.getColor("window"));
if (controller.getModel() != null) {
- setModel(controller.getModel(), controller.getModelRotation(),
+ setModel(controller.getModel(), controller.getModelRotation(),
controller.getWidth(), controller.getDepth(), controller.getHeight(), preferences);
} else {
setModel(null);
}
-
+
addMouseListener(new MouseAdapter() {
private boolean mousePressedInIcon;
@@ -1662,7 +1663,7 @@ public class FurniturePanel extends JPanel implements DialogView {
public void mousePressed(MouseEvent ev) {
this.mousePressedInIcon = true;
}
-
+
@Override
public void mouseReleased(MouseEvent ev) {
if (this.mousePressedInIcon) {
@@ -1691,39 +1692,39 @@ public class FurniturePanel extends JPanel implements DialogView {
PropertyChangeListener rotationChangeListener = new PropertyChangeListener () {
public void propertyChange(PropertyChangeEvent ev) {
setModelRotation(controller.getModelRotation());
-
+
// Update size when a new rotation is provided
if (ev.getOldValue() != null) {
float width = controller.getWidth();
float depth = controller.getDepth();
float height = controller.getHeight();
-
+
// Compute size before old model rotation
float [][] oldModelRotation = (float [][])ev.getOldValue();
Matrix3f oldModelRotationMatrix = new Matrix3f(oldModelRotation [0][0], oldModelRotation [0][1], oldModelRotation [0][2],
oldModelRotation [1][0], oldModelRotation [1][1], oldModelRotation [1][2],
oldModelRotation [2][0], oldModelRotation [2][1], oldModelRotation [2][2]);
oldModelRotationMatrix.invert();
- float oldWidth = oldModelRotationMatrix.m00 * width
- + oldModelRotationMatrix.m01 * height
+ float oldWidth = oldModelRotationMatrix.m00 * width
+ + oldModelRotationMatrix.m01 * height
+ oldModelRotationMatrix.m02 * depth;
- float oldHeight = oldModelRotationMatrix.m10 * width
- + oldModelRotationMatrix.m11 * height
+ float oldHeight = oldModelRotationMatrix.m10 * width
+ + oldModelRotationMatrix.m11 * height
+ oldModelRotationMatrix.m12 * depth;
- float oldDepth = oldModelRotationMatrix.m20 * width
- + oldModelRotationMatrix.m21 * height
+ float oldDepth = oldModelRotationMatrix.m20 * width
+ + oldModelRotationMatrix.m21 * height
+ oldModelRotationMatrix.m22 * depth;
-
+
// Compute size after new model rotation
float [][] newModelRotation = (float [][])ev.getNewValue();
- controller.setWidth(Math.abs(newModelRotation [0][0] * oldWidth
- + newModelRotation [0][1] * oldHeight
+ controller.setWidth(Math.abs(newModelRotation [0][0] * oldWidth
+ + newModelRotation [0][1] * oldHeight
+ newModelRotation [0][2] * oldDepth));
- controller.setHeight(Math.abs(newModelRotation [1][0] * oldWidth
- + newModelRotation [1][1] * oldHeight
+ controller.setHeight(Math.abs(newModelRotation [1][0] * oldWidth
+ + newModelRotation [1][1] * oldHeight
+ newModelRotation [1][2] * oldDepth));
- controller.setDepth(Math.abs(newModelRotation [2][0] * oldWidth
- + newModelRotation [2][1] * oldHeight
+ controller.setDepth(Math.abs(newModelRotation [2][0] * oldWidth
+ + newModelRotation [2][1] * oldHeight
+ newModelRotation [2][2] * oldDepth));
}
}
@@ -1752,13 +1753,13 @@ public class FurniturePanel extends JPanel implements DialogView {
controller.addPropertyChangeListener(FurnitureController.Property.HEIGHT,
sizeChangeListener);
}
-
+
/**
* Adds listeners to <code>controller</code> to update the face culling of the piece model
* displayed by this component.
*/
private void addBackFaceShownListener(final FurnitureController controller) {
- controller.addPropertyChangeListener(FurnitureController.Property.BACK_FACE_SHOWN,
+ controller.addPropertyChangeListener(FurnitureController.Property.BACK_FACE_SHOWN,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
if (controller.getBackFaceShown() != null) {
@@ -1767,7 +1768,7 @@ public class FurniturePanel extends JPanel implements DialogView {
}
});
}
-
+
/**
* Adds a listener to <code>controller</code> to update the model
* displayed by this component.
@@ -1777,31 +1778,31 @@ public class FurniturePanel extends JPanel implements DialogView {
controller.addPropertyChangeListener(FurnitureController.Property.MODEL,
new PropertyChangeListener () {
public void propertyChange(PropertyChangeEvent ev) {
- setModel(controller.getModel(), controller.getModelRotation(),
+ setModel(controller.getModel(), controller.getModelRotation(),
controller.getWidth(), controller.getDepth(), controller.getHeight(), preferences);
}
});
}
-
+
/**
- * Sets the 3D model viewed by this model
+ * Sets the 3D model viewed by this model
*/
public void setModel(final Content model, final float [][] modelRotation,
final Float width, final Float depth, final Float height,
final UserPreferences preferences) {
if (model == null) {
- setModel(null);
+ setModel(null);
} else {
- ModelManager.getInstance().loadModel(model, new ModelManager.ModelObserver() {
+ ModelManager.getInstance().loadModel(model, new ModelManager.ModelObserver() {
public void modelUpdated(BranchGroup modelRoot) {
- setModel(model);
+ setModel(model);
if (width != null && depth != null && height != null) {
setModelRotationAndSize(modelRotation, width, depth, height);
}
}
-
+
public void modelError(Exception ex) {
- JOptionPane.showMessageDialog(SwingUtilities.getRootPane(IconPreviewComponent.this),
+ JOptionPane.showMessageDialog(SwingUtilities.getRootPane(IconPreviewComponent.this),
preferences.getLocalizedString(FurniturePanel.class, "modelError"),
preferences.getLocalizedString(FurniturePanel.class, "errorTitle"),
JOptionPane.ERROR_MESSAGE);
@@ -1815,7 +1816,7 @@ public class FurniturePanel extends JPanel implements DialogView {
Insets insets = getInsets();
return new Dimension(PREFERRED_SIZE + insets.left + insets.right, PREFERRED_SIZE + insets.top + insets.bottom);
}
-
+
/**
* Resets view angles and scale.
*/
=====================================
src/com/eteks/furniturelibraryeditor/swing/package.properties
=====================================
@@ -119,10 +119,10 @@ EditorPane.about.message=<html><font face="sanssherif"><center><font size="+2"><
<br><font size="-1">SVG path compilation provided by Batik</font>\
<p>Please, visit http://www.sweethome3d.com/\
<br>for software updates and bug report.\
- </p><p><font size="-2">\u00a9 Copyrights 2010-2018 eTeks info at eteks.com\
+ </p><p><font size="-2">\u00a9 Copyrights 2010-2019 eTeks info at eteks.com\
<br>Distributed under GNU General Public License</font>
# Note to translators: dot not copy the 2 following keys in localized file
-EditorPane.about.version=1.23
+EditorPane.about.version=1.24
EditorPane.about.icon=/com/eteks/furniturelibraryeditor/swing/resources/aboutIcon.png
=====================================
src/com/eteks/furniturelibraryeditor/swing/package_fr.properties
=====================================
@@ -79,7 +79,7 @@ EditorPane.about.message=<html><font face="sanssherif"><center><font size="+2"><
<br><font size="-1">Compilation SVG path fournie par Batik</font>\
<p>Rendez-vous sur http://www.sweethome3d.com/fr/\
<br>pour mettre jour ce logiciel ou faire des suggestions.\
- </p><p><font size="-2">\u00a9 Copyrights 2010-2018 eTeks info at eteks.com\
+ </p><p><font size="-2">\u00a9 Copyrights 2010-2019 eTeks info at eteks.com\
<br>Distribu sous licence GNU General Public License</font>
FurnitureLanguageComboBox.defaultLanguage=Langue par dfaut
View it on GitLab: https://salsa.debian.org/java-team/sweethome3d-furniture-editor/commit/edf0f6871affdd43a773b2d69eac3d12d1289e6f
--
View it on GitLab: https://salsa.debian.org/java-team/sweethome3d-furniture-editor/commit/edf0f6871affdd43a773b2d69eac3d12d1289e6f
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190128/704b0a24/attachment.html>
More information about the pkg-java-commits
mailing list