public void disconnected() { isConnected = false; MainFrame.getInstance().setDisconnected(); SwingUtilities.invokeLater( new Runnable() { public void run() { uploadModel.removeExternalUploads(); downloadModel.removeExternalDownloads(); } }); logger.severe("disconnected!"); }
/** Set view selection to user's choice. */ public void setSelect() throws DatabaseException { JList list = getList(); View original = null; View view = null; long id = _collection.getDatabase().getCurrentSetting().getViewID(); if (id != -1) { for (int i = 0; i < list.getModel().getSize(); i++) { View vw = (View) list.getModel().getElementAt(i); if (id == vw.getID()) { view = vw; break; } else if (vw.getName().equals("Original")) { original = view; } } } // default Original if (view == null) view = original; list.setSelectedValue(view, true); MainFrame.getInstance().updateStatus(); }
public void connected() { isConnected = true; MainFrame.getInstance().setConnected(); logger.severe("now connected"); }
public static void zoomToFit(Viewport2 viewport) { ViewDefinition viewdef = viewport.getViewDefinition(); // if (MainFrame.getInstance().getMeshToolBar().getMode() != MeshToolBar.VIEW_ZOOM) { // MainFrame.getInstance().getJPatchScreen().removeAllMouseListeners(); // MainFrame.getInstance().getJPatchScreen().addMouseListeners(new // ChangeViewMouseListener(MouseEvent.BUTTON1,ChangeViewMouseListener.ZOOM)); // MainFrame.getInstance().getMeshToolBar().setMode(MeshToolBar.VIEW_ZOOM); // } else { // MainFrame.getInstance().getMeshToolBar().reset(); // } Selection selection = MainFrame.getInstance().getSelection(); float left = Float.MAX_VALUE; float right = -Float.MAX_VALUE; float bottom = Float.MAX_VALUE; float top = -Float.MAX_VALUE; Point3f p3 = new Point3f(); Matrix4f m4View = viewdef.getScreenMatrix(); // Matrix3f m3RotScale = new Matrix3f(); // m4View.getRotationScale(m3RotScale); boolean doit = true; if (selection != null && !selection.isSingle()) { for (Iterator it = selection.getObjects().iterator(); it.hasNext(); ) { Object object = it.next(); if (object instanceof ControlPoint) { p3.set(((ControlPoint) object).getPosition()); m4View.transform(p3); if (p3.x < left) left = p3.x; if (p3.x > right) right = p3.x; if (p3.y < bottom) bottom = p3.y; if (p3.y > top) top = p3.y; } } } else { ArrayList heads = MainFrame.getInstance().getModel().allHeads(); int p = 0; for (Iterator it = heads.iterator(); it.hasNext(); ) { ControlPoint cp = (ControlPoint) it.next(); if (!cp.isHidden()) { p3.set(cp.getPosition()); m4View.transform(p3); if (p3.x < left) left = p3.x; if (p3.x > right) right = p3.x; if (p3.y < bottom) bottom = p3.y; if (p3.y > top) top = p3.y; p++; } } doit = (p >= 2); } if (doit) { // System.out.println(left + " " + right + " " + top + " " + bottom + " " + // viewdef.getScale()); // System.out.println(viewdef.getTranslateX() + " " + viewdef.getTranslateY()); float centerX = (left + right) / 2f; float centerY = (top + bottom) / 2f; float dimX = viewdef.getWidth() / 2f; float dimY = viewdef.getHeight() / 2f; float sizeX = right - centerX; float sizeY = top - centerY; if (sizeX > 0 || sizeY > 0) { // System.out.println(centerX + ":" + centerY); float scaleX = dimX / sizeX; float scaleY = dimY / sizeY; float scale = Math.min(scaleX, scaleY) * 0.9f; // viewdef.setScale(viewdef.getScale() * scale); viewdef.setLock(null); viewdef.moveView(-centerX / dimX + 1, (dimY - centerY) / dimX, false); viewdef.scaleView(scale); // viewdef.setTranslation(centerX, centerY); // viewdef.computeMatrix(); // viewport.render(); } } }
public void actionPerformed(ActionEvent actionEvent) { zoomToFit(MainFrame.getInstance().getJPatchScreen().getActiveViewport()); }
ViewsPane(WordCollection collection) { super(null, true, true, false); final Messages messages = AppPrefs.getInstance().getMessages(); // change find label setFindButtonLabel(messages.getString("btnFindViews")); _collection = collection; getList().setModel(new BasicListModel()); final MainFrame mf = MainFrame.getInstance(); ListSelectionModel model = getList().getSelectionModel(); model.addListSelectionListener( new ListSelectionListener() { public synchronized void valueChanged(ListSelectionEvent evt) { try { View view = (View) getList().getSelectedValue(); if (view != null) { Setting setting = _collection.getDatabase().getCurrentSetting(); setting.setViewID(view.getID()); setting.save(); mf.updateStatus(); } } catch (DatabaseException e) { Dialogs.genericError(e); } } }); addAddEditDeleteListener( new AddEditDeleteListener() { public void doAdd(ActionEvent evt) throws DatabaseException { final View view = _collection.makeView(); AddDialog dialog = new AddDialog("lblAddView", view); dialog.setVisible(true); if (!dialog.isCancelled()) { // add default groups and alignments AddRunnable task = new AddRunnable() { public void run() { try { ViewDuplicator.makeGroupsAndAlignments(view, view, _collection, false); // update collection view list List views = _collection.getViews(); views.add(view); _collection.getDatabase().getCurrentSetting().setViewID(view.getID()); refresh(); } catch (DatabaseException ex) { exception = ex; } } DatabaseException exception = null; public DatabaseException getException() { return exception; } }; Messages m = AppPrefs.getInstance().getMessages(); Dialogs.indeterminateProgressDialog( task, m.getString("pgbWaitString"), m.getString("pgbCurrentTask") + m.getString("lblAddView")); if (task.getException() != null) { // so we don't swallow the exception from the other thread. throw task.getException(); } } } public void doCopy(ActionEvent evt) throws DatabaseException { ViewDuplicator duplicator = new ViewDuplicator((View) getList().getSelectedValue(), _collection); TaskDialog dialog = new TaskDialog("lblViewCopy", duplicator); dialog.setVisible(true); if (!dialog.isCancelled()) { // update collection view list List views = _collection.getViews(); View view = duplicator.getDuplicate(); if (view != null) { // view will be null if attempted duplicate view name. views.add(view); _collection.getDatabase().getCurrentSetting().setViewID(view.getID()); refresh(); } } } public void doDelete(ActionEvent evt) throws DatabaseException { View view = (View) getList().getSelectedValue(); // check for Original view View original = _collection.getOriginalView(); if (view.equals(original)) { Dialogs.error(messages.getString("msgErrDeletingOriginalView")); } else { view.delete(); // update collection view list List views = _collection.getViews(); views.remove(view); changeView(original); JSplitPane split = (JSplitPane) getMainComponent(); int loc = split.getDividerLocation(); split.setRightComponent(new JLabel("")); split.setDividerLocation(loc); refresh(); } } public void doValidate(ActionEvent evt) {} public void doMoveUp(ActionEvent evt) {} public void doMoveDown(ActionEvent evt) {} }); getList().setCellRenderer(new ViewNameListCellRenderer()); }