Loading GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java 0 → 100644 +85 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.core; import java.awt.BorderLayout; import java.text.SimpleDateFormat; import java.time.Duration; import javax.swing.JScrollPane; import javax.swing.JTextArea; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; /** * Wrapper for default output window of the Java Netbeans Platform application. * It enables to write debug messages into the window. * * @author Radek Oslejsek */ public class OutputWindow { private final JTextArea textArea; private long lastTime = System.currentTimeMillis(); private static OutputWindow instance; protected OutputWindow() { TopComponent outputWin = WindowManager.getDefault().findTopComponent("output"); textArea = new JTextArea(); JScrollPane sp = new JScrollPane(textArea); outputWin.add(sp, BorderLayout.CENTER); } /** * Prints the message. The duration indicator is set to [+00:00:000] * * @param msg Message to be printed */ public static void print(String msg) { instance().textArea.setText(instance().textArea.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) + " [+00:00:000]: " + msg.trim() + System.lineSeparator() ); } /** * Resets the stopwatch for the duration calculation. */ public static void resetStopwatch() { instance().lastTime = System.currentTimeMillis(); } /** * Prints the message about an operation and the duration of the operation. * The duration is computed as the difference between current system time and * the time of calling {@link #resetStopwatch()}. The difference is measured in * milliseconds and printed as [+mm:ss.SSS] where mm=minutes, ss=seconds, * and SSS=milliseconds. * * @param msg Message to be printed */ public static void printDuration(String msg) { Duration duration = Duration.ofMillis(System.currentTimeMillis() - instance().lastTime); instance().textArea.setText(instance().textArea.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) + " [+" + String.format( "%d:%02d.%03d", duration.toMinutes(), duration.toSecondsPart(), duration.toMillisPart()) + "]: " + msg.trim() + System.lineSeparator() ); } protected static OutputWindow instance() { if (instance == null) { instance = new OutputWindow(); } return instance; } } GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java +2 −0 Original line number Diff line number Diff line Loading @@ -470,8 +470,10 @@ public final class ProjectTopComp extends TopComponent { if (file == null) { System.out.print("No file chosen."); } else { OutputWindow.resetStopwatch(); String faceId = HumanFaceFactory.instance().loadFace(file); HumanFace face = HumanFaceFactory.instance().getFace(faceId); OutputWindow.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); try { // simple hack: Loading MeshModel/src/main/java/cz/fidentis/analyst/mesh/core/MeshModel.java +11 −0 Original line number Diff line number Diff line Loading @@ -170,4 +170,15 @@ public class MeshModel implements Serializable { } return facets.size() + " facets with " + verts + " vertices"; } /** * Returns number of vertices }sum of all facets). * @return Number of vertices */ public long getNumVertices() { //int ret = 0; //facets.stream().map(f -> f.getNumberOfVertices()).reduce(ret, Integer::sum); //return ret; return facets.stream().map(f -> f.getNumberOfVertices()).reduce(0, Integer::sum); } } Loading
GUI/src/main/java/cz/fidentis/analyst/core/OutputWindow.java 0 → 100644 +85 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.core; import java.awt.BorderLayout; import java.text.SimpleDateFormat; import java.time.Duration; import javax.swing.JScrollPane; import javax.swing.JTextArea; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; /** * Wrapper for default output window of the Java Netbeans Platform application. * It enables to write debug messages into the window. * * @author Radek Oslejsek */ public class OutputWindow { private final JTextArea textArea; private long lastTime = System.currentTimeMillis(); private static OutputWindow instance; protected OutputWindow() { TopComponent outputWin = WindowManager.getDefault().findTopComponent("output"); textArea = new JTextArea(); JScrollPane sp = new JScrollPane(textArea); outputWin.add(sp, BorderLayout.CENTER); } /** * Prints the message. The duration indicator is set to [+00:00:000] * * @param msg Message to be printed */ public static void print(String msg) { instance().textArea.setText(instance().textArea.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) + " [+00:00:000]: " + msg.trim() + System.lineSeparator() ); } /** * Resets the stopwatch for the duration calculation. */ public static void resetStopwatch() { instance().lastTime = System.currentTimeMillis(); } /** * Prints the message about an operation and the duration of the operation. * The duration is computed as the difference between current system time and * the time of calling {@link #resetStopwatch()}. The difference is measured in * milliseconds and printed as [+mm:ss.SSS] where mm=minutes, ss=seconds, * and SSS=milliseconds. * * @param msg Message to be printed */ public static void printDuration(String msg) { Duration duration = Duration.ofMillis(System.currentTimeMillis() - instance().lastTime); instance().textArea.setText(instance().textArea.getText() + new SimpleDateFormat("HH:mm:ss").format(System.currentTimeMillis()) + " [+" + String.format( "%d:%02d.%03d", duration.toMinutes(), duration.toSecondsPart(), duration.toMillisPart()) + "]: " + msg.trim() + System.lineSeparator() ); } protected static OutputWindow instance() { if (instance == null) { instance = new OutputWindow(); } return instance; } }
GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java +2 −0 Original line number Diff line number Diff line Loading @@ -470,8 +470,10 @@ public final class ProjectTopComp extends TopComponent { if (file == null) { System.out.print("No file chosen."); } else { OutputWindow.resetStopwatch(); String faceId = HumanFaceFactory.instance().loadFace(file); HumanFace face = HumanFaceFactory.instance().getFace(faceId); OutputWindow.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); try { // simple hack: Loading
MeshModel/src/main/java/cz/fidentis/analyst/mesh/core/MeshModel.java +11 −0 Original line number Diff line number Diff line Loading @@ -170,4 +170,15 @@ public class MeshModel implements Serializable { } return facets.size() + " facets with " + verts + " vertices"; } /** * Returns number of vertices }sum of all facets). * @return Number of vertices */ public long getNumVertices() { //int ret = 0; //facets.stream().map(f -> f.getNumberOfVertices()).reduce(ret, Integer::sum); //return ret; return facets.stream().map(f -> f.getNumberOfVertices()).reduce(0, Integer::sum); } }