Romania
Joined: Apr 24, 2014
Post Count: 588
Status:
Offline
Re: Generate roof plugin
Sorry for the late reaction. I have a big cervical pain for a week and it doesn't stop yet. Your new arrangement look like this: <DMA-01>
<DMA-02>
Some comments: 1. The single thing I've do was to add 2 spaces after the degree sign to make it more legible and increase the edge field (red arrow on DMA-01) 2. As you can see, to add extra rows don't change (improve) the aspect. The grid don't have a fixed size. 3. I've also used the Deutsch translations to show you how to different LaF render it.(red ellipses). 3.1. The truncated long text it's an old problem. 3.2. I'm curious how other applications have solve this in germane (LO, Blender, LibreCAD etc) 3.3. My solution was to find words as short as possible to use in titles and add some Tool tips with a large description.(eg. Thick in place of Thicknesses) 3.3.1 This has to be the translators task. For sample:Böschungsneigung could be replaced with Winkel or Feinjustierung with Fein 3.4. All this are necessary to keep an homogeneity between systems and their custom LaFs. 4. Some of my opinions about the ergonomy of a UI application: 4.1. Like in reading: from left to right and from top to bottom. 4.2. The most used near to top, continuing down with rarely used and finished with bottom OK or Cancel. 4.3. Almost all devices have a Reset button. Almost always is hard accessible to prevent accidental actions. So, in my opinion, considering this, I put the Reset button on top right corner, away from used controls an Ok button. I've thinking (from my personal experience), after a half of hour of work to fine tuning a roof to finally press Reset in place of Ok. Well, most users probably aren't as old and stupid as me, but preemptively... 5. My arrangement also takes care of possible future improvements. (Look at the probably v5.0, if will ever be)
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law (Greer's Third Law) When all else fails, read the instructions.Murphy's Law
France
Joined: Nov 7, 2005
Post Count: 9371
Status:
Offline
Re: Generate roof plugin
Dorin, get a good rest, Sweet Home 3D doesn’t worth that you get more pain
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
/** * Creates and layout the components shown in the dialog box of this plug-in. * * @author Daniels118 * * @param homeView * @param resource */ protected void createComponents(final HomeView homeView, final ResourceBundle resource) { UserPreferences preferences = plugin.getUserPreferences(); String unitName = preferences.getLengthUnit().getName();
// Create a common change listener for some components. commonListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent ev) { if (ev.getSource().equals(showHome)) { if (showHome.getValue()) { plugin.homeItems.removeAllChildren(); plugin.homeItems = plugin.createHomeNode(plugin.getHome()); } plugin.refreshRoof(homeView, resource);
} else if (ev.getSource().equals(faceAngleSlider)) { int slope = faceAngleSlider.getValue(); int maxAngle = faceAngleSlider.getMaximum() - 1; // Limit the slope in range 1 to 179 degrees slope = slope > 1 ? slope : 1; slope = slope < maxAngle ? slope : maxAngle; // Update the angle for the selected faces for (SlopedEdge edge : edgesList.getSelectedValuesList()) edge.setSlope(slope); fineSlope.removeChangeListener(commonListener); fineSlope.setValue(0.0); fineSlope.addChangeListener(commonListener); if (!faceAngleSlider.getValueIsAdjusting() && faceAngleSlider.hasFocus()) { edgesList.updateUI(); plugin.updateSelectedFacesFromList(homeView, resource); } } else if (ev.getSource().equals(fineSlope)) { // Add the fine tuning to edge slope float fineSlopeVal = ((Number) fineSlope.getValue()).floatValue(); float angle = faceAngleSlider.getValue(); float maxAngle = faceAngleSlider.getMaximum() - 1; float slope = angle + fineSlopeVal; slope = slope > 1f ? slope : 1.0f; slope = slope < maxAngle ? slope : maxAngle; // Update the angle for the selected faces for (SlopedEdge edge : edgesList.getSelectedValuesList()) edge.setSlope(slope); edgesList.updateUI(); plugin.updateSelectedFacesFromList(homeView, resource); } else if (ev.getSource().equals(invisibilityCheck)) { if (invisibilityCheck.getValue() != null) { boolean visible = !invisibilityCheck.getValue(); // Update the face visibility for (SlopedEdge edge : edgesList.getSelectedValuesList()) edge.setFaceVisible(visible); edgesList.updateUI(); plugin.updateSelectedFacesFromList(homeView, resource); } } else { plugin.refreshRoof(homeView, resource); } } };
// Create edges list selection listener. edgesListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent ev) { int edgeSelection = edgesList.getSelectedIndices().length; // Limit selection to have at least one face with slope < 90 deg int maxAngle = edgeSelection < plugin.allRoofEdges.length ? 180 : 76; if (faceAngleSlider.getMaximum() != maxAngle) faceAngleSlider.setMaximum(maxAngle); SlopedEdge edge = edgesList.getSelectedValue(); if (edge != null) { // Set angle faceAngleSlider.removeChangeListener(commonListener); faceAngleSlider.setValue((int) edge.getSlope()); faceAngleSlider.addChangeListener(commonListener); // Set fine slope fineSlope.removeChangeListener(commonListener); fineSlope.setValue(edge.getSlope() - faceAngleSlider.getValue()); fineSlope.addChangeListener(commonListener); } if (!ev.getValueIsAdjusting() && edgesList.hasFocus()) plugin.updateSelectedFacesFromList(homeView, resource); } }; // Create preview roofPreview = new ModelPreviewComponent(true, true, true, true); roofPreview.setFocusable(false); roofPreview.setPreferredSize(new Dimension((int) (800 * resolutionScale), (int) (600 * resolutionScale)));// @byDMA resizing window to 800x600 // Add a mouse listener to get selected faces roofPreview.addMouseListener(new MouseAdapter() { private Set<SlopedEdge> selectedEdges = new HashSet<SlopedEdge>();// Using a set avoids duplicates
@Override public void mouseClicked(MouseEvent ev) { HomeMaterial pickedMaterial = roofPreview.getPickedMaterial(); boolean sInterval = false; if (pickedMaterial != null) { String faceName = pickedMaterial.getName(); for (RoofFace face : plugin.faces) { if (faceName.equals(face.getFaceName())) { if ((ev.getModifiers() & Event.CTRL_MASK) != 0 || (ev.getModifiers() & Event.SHIFT_MASK) != 0) { for (SlopedEdge sEdge : face.getGeneratingEdges()) { if (!selectedEdges.add(sEdge)) selectedEdges.remove(sEdge);// Toggle selection } if ((ev.getModifiers() & Event.SHIFT_MASK) != 0) sInterval = true; } else { selectedEdges.clear(); for (SlopedEdge sEdge : face.getGeneratingEdges()) selectedEdges.add(sEdge); } break;// There can be a single face matching the picked material } } int[] edgeIndices = new int[selectedEdges.size()]; int i = 0; for (SlopedEdge sEdge : selectedEdges) edgeIndices[i++] = sEdge.getEdge(); edgesList.setSelectedIndices(edgeIndices); int sMin = edgesList.getMinSelectionIndex(); int sMax = edgesList.getMaxSelectionIndex(); if (sInterval) edgesList.addSelectionInterval(sMin, sMax); if (i > 0) edgesList.ensureIndexIsVisible(edgeIndices[i - 1]); } else if ((ev.getModifiers() & Event.CTRL_MASK) == 0) { edgesList.setSelectedIndices(new int[0]);// Deselect when click the background } edgesList.updateUI(); plugin.updateSelectedFacesFromList(homeView, resource); } });
// Create edges list // String edgesLabel = resource.getString("edges.txt");// Edges: Slope edgesList = new JList<SlopedEdge>(); edgesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); edgesList.setListData(plugin.allRoofEdges);// Add edges to the list edgesList.setCellRenderer(new EdgesCellRenderer()); edgesList.addListSelectionListener(edgesListener); edgesList.setFixedCellWidth(140);// byDMA resize width of the List in the JScrollPane // Put edges list into scroll panel String edgesLab = resource.getString("edges.txt");// Edges: Slope edgesLabel = new JLabel(edgesLab);// Edges: Slope // scrollEdges = SwingTools.createScrollPane(edgesList); scrollEdgesPane = new JScrollPane(edgesList); if (OperatingSystem.isMacOSX()) { Dimension preferredSize = scrollEdgesPane.getPreferredSize(); scrollEdgesPane.setPreferredSize(new Dimension(Math.min(200, preferredSize.width), preferredSize.height)); } else {
// Create home visibility check box String displayHome = resource.getString("displayHomeCheckBox.txt");// Show home showHome = new NullableCheckBox(displayHome); showHome.setValue(false); showHome.addChangeListener(commonListener);
// Create texture visibility check box String useTexture = resource.getString("displayTextureCheckBox.txt");// Use roof texture showTexture = new NullableCheckBox(useTexture); showTexture.setValue(false); showTexture.setEnabled(plugin.isRoofSelected()); showTexture.addChangeListener(commonListener);
// First refresh roof edgesList.updateUI(); plugin.refreshRoof(plugin.homeView, plugin.resource); return roofPanel; }
private class EdgesCellRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = 1L; final ImageIcon eyeCloseIcon = new ImageIcon(GenerateRoofPlugin.class.getResource("/generateroof/resources/closed-eye.png")); final ImageIcon emptyIcon = new ImageIcon(GenerateRoofPlugin.class.getResource("/generateroof/resources/emptyIcon.png"));
@Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String s = value.toString(); setText(s); boolean visible = plugin.allRoofEdges[index].isFaceVisible(); setIcon(!visible ? eyeCloseIcon : emptyIcon);
GERMANY | POLAND
Joined: Jun 8, 2024
Post Count: 25
Status:
Offline
Re: Generate roof plugin
it is a hole file GenerateRoofPluginView.java
I have changed the: 1. windows size to 800x600 2. about button 3. Edge-Panel list width -> should resize the scroll panel width 4. autor TextField -> set manually width to 250, this should resize the columns width 6-7
Romania
Joined: Apr 24, 2014
Post Count: 588
Status:
Offline
Re: Generate roof plugin
@1. The preview size you've propose could be good. @2. The About button will remain GREEN for my public versions. Some people could receive a customized version. @3. Could be a solution but it is away too wide for other languages. A compromise could be to replace Edges:Slope (Kanten: Neigung) text with only Edges (Kanten). Another solution could be to replace JList with JTable or Jeks and include a header. The invisibility checkbox could be also added for every edge to replace the eye indicator. @4. This setting has not the expected effect.
it is a hole file GenerateRoofPluginView.java
You've modified few lines: 177, 231, 344(// Need cast int), 346, 421, 422 (//Wrong), 478. For the above lines was enough to make proposal like in patches. For the createUI method it's Ok to post it entirely as you've done in the paste.
I hope to not upset you. I'm not a programmer so my opinion don't count too much.
---------------------------------------- A computer program does what you tell it to do, not what you want it to do. Murphy's Law (Greer's Third Law) When all else fails, read the instructions.Murphy's Law
France
Joined: Nov 7, 2005
Post Count: 9371
Status:
Offline
Re: Generate roof plugin
byDMA, creating a repository is probably not something that will help Dorin to rest and recover at the moment. I already asked him in the past if he could improve the layout of his plug-in to make it more compliant under macOS, something that he performed very gently. Maybe, we shouldn’t ask him perfection and anyway, the look and feel of a user interface always depends on one’s taste.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
GERMANY | POLAND
Joined: Jun 8, 2024
Post Count: 25
Status:
Offline
Re: Generate roof plugin
So, here we are. I compiled it myself and experimented with the sizes. Now it does not matter which language is used and how long or short the words are in the TittledBorder. There is no need to do tricks with the words when translating. I also tried to distribute the components and the distances evenly.
Only this is needed: 1. fix width of the edgeList
edgesList.setFixedCellWidth(200);// byDMA resize width of the List in the JScrollPane
2. corrected grids explained: ipadx changes the width of JScrollPanel with the EdgeList. scrollEdgesPane -> 200 faceAngleSlider -> 125