private void broadcast() { Iterator i = _listeners.iterator(); ChangeEvent event = new ChangeEvent(this); while (i.hasNext()) { ((ChangeListener) (i.next())).stateChanged(event); } }
/** draw the arrows between items */ public void paintComponent(Graphics g) { super.paintComponent(g); if (_glist != null && _glist.size() > 1) { Graphics2D g2 = (Graphics2D) g; Arrow leftArrow = new Arrow(); leftArrow.setColor(Color.BLACK); Arrow rightArrow = new Arrow(); rightArrow.setColor(Color.RED); Iterator<GNode> iter = _glist.iterator(); while (iter.hasNext()) { GNode nCur = iter.next(); if (nCur.left != null) { leftArrow.setLine(nCur.getStart(), nCur.left.getEnd()); leftArrow.draw(g2); } if (nCur.right != null) { rightArrow.setLine(nCur.getStart(), nCur.right.getEnd()); rightArrow.draw(g2); } } } }
public void updateConnectionStatus(boolean connected) { if (connected == true) { headerPanel.setLogoutText(); loginMenuItem.setText("Logout"); } else { headerPanel.setLoginText(); loginMenuItem.setText("Login..."); } mainCommandPanel.updateConnectionStatus(connected); propertiePanel.updateConnectionStatus(connected); cmdConsole.updateConnectionStatus(connected); Iterator iterator = plugins.iterator(); PluginPanel updatePluginPanel = null; while (iterator.hasNext()) { updatePluginPanel = (PluginPanel) iterator.next(); updatePluginPanel.updateConnectionStatus(connected); } if (connected == true) { int selected = tabbedPane.getSelectedIndex(); if (selected >= 2) { ((PluginPanel) pluginPanelMap.get("" + selected)).activated(); } } }
private void createPainToTree3true( final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection paintCollection) { ArrayList a = (ArrayList) paintCollection; Iterator i = a.iterator(); Person p = null; Person parent = null; DefaultMutableTreeNode parentNode = root; DefaultMutableTreeNode newNode; while (i.hasNext()) { p = (Person) i.next(); int ves, ves2; if (parent != null) { parent = (Person) parentNode.getUserObject(); ves = comparePerson(p, (Person) parentNode.getUserObject()); ves2 = comparePersonAsString(p, (Person) parentNode.getUserObject()) + 1; System.out.println("ves = " + ves + " ves2= " + ves2); switch (ves) { case 0: { parentNode = root; parent = null; break; } case 1: { } } } newNode = new DefaultMutableTreeNode(p); parentNode.add(newNode); parent = p; parentNode = newNode; } }
InstanceListModel(ASDGrammar grammar, String word) { ArrayList instanceList = grammar.lookupWord(word); for (Iterator it = instanceList.iterator(); it.hasNext(); ) { ASDGrammarNode n = (ASDGrammarNode) it.next(); String instance = (String) n.instance(); this.addElement(instance); } }
/** * When we change to a new DS, need to get all the JComponents that have been added to the JPanel * and remove them! */ private void cleanupGNodes() { if (_glist == null) return; Iterator<GNode> iter = _glist.iterator(); while (iter.hasNext()) { GNode gNode = iter.next(); this.remove(gNode); } }
public void addListener(DMoteModelListener listener) { if (listeners == null) listeners = new ArrayList(); Iterator it = listeners.iterator(); while (it.hasNext()) { if (it.next() == listener) return; } ; listeners.add(listener); }
public void removeListener(DMoteModelListener listener) { if (listeners == null) return; Iterator it = listeners.iterator(); while (it.hasNext()) { if (it.next() == listener) { it.remove(); return; } } }
public void initAgents(ArrayList machineAgentArray) { fUGeneralStrategy = new UBaseAgent("su", "supasswd", "Super User", 0); fServer.appendStrategy(fUGeneralStrategy); fCProtocol = fUGeneralStrategy.getUmcp(); fCommandHashMap = fCProtocol.getCommandHashMap(); Iterator iter = machineAgentArray.iterator(); while (iter.hasNext()) { fServer.appendStrategy((UBaseAgent) iter.next()); } }
private void applyChanges() { boolean changedFieldSet = false; // Watch if we need to rebuild entry editors // First remove the mappings for fields that have been deleted. // If these were re-added, they will be added below, so it doesn't // cause any harm to remove them here. for (Iterator<String> i = removedFields.iterator(); i.hasNext(); ) { String fieldName = i.next(); metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName); changedFieldSet = true; } // Cycle through all fields that we have created listmodels for: loop: for (Iterator<String> i = wordListModels.keySet().iterator(); i.hasNext(); ) { // For each field name, store the values: String fieldName = i.next(); if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) continue loop; DefaultListModel lm = wordListModels.get(fieldName); int start = 0; // Avoid storing the <new word> marker if it is there: if (lm.size() > 0) while ((start < lm.size()) && (lm.get(start)).equals(WORD_FIRSTLINE_TEXT)) start++; Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName); boolean newField = false; if (data == null) { newField = true; data = new Vector<String>(); changedFieldSet = true; } else data.clear(); for (int wrd = start; wrd < lm.size(); wrd++) { String word = (String) lm.get(wrd); data.add(word); } if (newField) metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data); } // System.out.println("TODO: remove metadata for removed selector field."); panel.markNonUndoableBaseChanged(); // Update all selectors in the current BasePanel. if (changedFieldSet) { panel.rebuildAllEntryEditors(); } else { panel.updateAllContentSelectors(); } panel.addContentSelectorValuesToAutoCompleters(); }
private void btnNuevaConstruccion_actionPerformed(ActionEvent e) { alta = true; Iterator alIt = Construcciones.iterator(); while (alIt.hasNext()) { try { JComponent comp = (JComponent) alIt.next(); if (comp instanceof JTextField) ((JTextField) comp).setText(""); if (comp instanceof JCheckBox) ((JCheckBox) comp).setSelected(false); if (comp instanceof JComboBox) ((JComboBox) comp).setSelectedIndex(0); } catch (Exception A) { A.printStackTrace(); } } }
public void mouseDragged(MouseEvent e) { if (!e.isShiftDown()) // normal drag move(this, e); else // drag entire connected component { ArrayList connectedNodes = dNode.connectedNodes(); if (connectedNodes.size() == 0) move(this, e); else for (Iterator it = connectedNodes.iterator(); it.hasNext(); ) { ASDDigraphNode dNode2 = (ASDDigraphNode) it.next(); ASDEditNode eNode2 = dNode2.getEditNode(); move(eNode2, e); } } getEditor().setGrammarChanged(true); getContext().repaint(); }
@NotNull private static List<RunnerAndConfigurationSettings> getAvailableConfigurations( RunConfiguration runConfiguration) { Project project = runConfiguration.getProject(); if (project == null || !project.isInitialized()) return Collections.emptyList(); final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); final ArrayList<RunnerAndConfigurationSettings> configurations = new ArrayList<RunnerAndConfigurationSettings>(runManager.getSortedConfigurations()); String executorId = DefaultRunExecutor.getRunExecutorInstance().getId(); for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext(); ) { RunnerAndConfigurationSettings settings = iterator.next(); final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings); if (runner == null || settings.getConfiguration() == runConfiguration) iterator.remove(); } return configurations; }
public static String[] genIndMenu(ArrayList<Object> source) { String[] menu = new String[source.size()]; Iterator indIter = source.iterator(); Individual ind; String item; int ndex = 0; while (indIter.hasNext()) { ind = (Individual) indIter.next(); item = "<no name>"; if ((ind.name != null) && (ind.name.length() > 0)) { item = ind.homeChart + ": " + ind.name; } item += " <" + ind.serialNmbr + ">"; if (ind.deleted) { item += " DELETED"; } menu[ndex++] = item; } return menu; } // end of method genIndMenu(source)
public void enter() { // Recuperamos el ID_Parcela y el ID_UnidadConstruccion AppContext app = (AppContext) AppContext.getApplicationContext(); Blackboard Identificadores = app.getBlackboard(); ID_Parcela = Integer.parseInt(Identificadores.get("ID_Parcela").toString()); // ID_Unidad= Integer.parseInt(Identificadores.get("ID_Unidad").toString()); // Rellenamos el Listbox lstCons.clear(); try { CatastroActualizarPostgre Cons = new CatastroActualizarPostgre(); ArrayList Datos = Cons.Cons(ID_Parcela); Iterator alIt = Datos.iterator(); while (alIt.hasNext()) { lstCons.addElement(alIt.next()); } } catch (Exception e) { e.printStackTrace(); } }
/** * React to the pushing of the given button * * @param index The number of the button pushed */ private void slide(int index) { // Don't do anything if the puzzle is solved if (solved) return; // if not a valid click return if (!check(index)) { return; } // swap positions current.set(index, current.set(hiddenIndex, current.get(index))); // swap strings JButton b = (JButton) buttons.get(index); b.setText((String) current.get(index)); b.setIcon(icons[Integer.parseInt(current.get(index)) - 1]); b.setVisible(false); b = (JButton) buttons.get(hiddenIndex); b.setText((String) current.get(hiddenIndex)); b.setIcon(icons[Integer.parseInt(current.get(hiddenIndex)) - 1]); b.setVisible(true); // update the position of the blanked spot hiddenIndex = index; // Increment the number of moves and update status moves++; getStatusLabel().setText("Number of moves: " + moves); // if you've won if (current.equals(correct)) { solved = true; getStatusLabel().setText("Solved the game in " + moves + " moves."); // Change the buttons colors to green Iterator itr = buttons.iterator(); while (itr.hasNext()) { ((JButton) itr.next()).setBackground(java.awt.Color.green); } } }
private void createPainToTree2( final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection paintCollection) { ArrayList a = (ArrayList) paintCollection; DefaultMutableTreeNode parent = root; System.out.println("a = " + a.size()); Iterator i = a.iterator(); // Person lastPerson = null; while (i.hasNext()) { Person p = (Person) i.next(); Object[] pathTree = { root, p.getFio().getLastName(), p.getFio().getMidllName(), p.getFio().getFirstName() }; // int poz=Arrays.binarySearch(pathTree, parent.getUserObject()); List l = Arrays.asList(pathTree); int poz = l.lastIndexOf(parent.getUserObject()); while (poz > -1) { // bvtyf yt cjdgflf.n while (pathTree.length > poz) { DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(pathTree[poz + 1]); treeModel.insertNodeInto(newNode, parent, parent.getChildCount()); parent = newNode; poz = Arrays.binarySearch(pathTree, parent.getUserObject()); } } // TreePath path = new TreePath(pathTree); // TreeNode[] pa = parent.getPath(); // Object[] o = parent.getUserObjectPath(); // if (p.getFio().getFirstName() != (o[o.length - 1])) { // // treeModel.insertNodeInto( // new DefaultMutableTreeNode( // path.getLastPathComponent()), // parent, parent.getChildCount()); // lastPerson = p; // } } }
private void createPainToTree( final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection c) { ArrayList a = (ArrayList) c; System.out.println("a = " + a.size()); Iterator i = a.iterator(); DefaultMutableTreeNode lastN = new DefaultMutableTreeNode(""); DefaultMutableTreeNode midlN = new DefaultMutableTreeNode(""); DefaultMutableTreeNode fistN = new DefaultMutableTreeNode(""); while (i.hasNext()) { Person p = (Person) i.next(); if (p.getFio().getLastName().equals((String) lastN.getUserObject())) { // совпала фамили¤ if (p.getFio().getMidllName().equals((String) midlN.getUserObject())) { if (p.getFio().getFirstName().equals((String) fistN.getUserObject())) { // treeModel.insertNodeInto(fistN,midlN,0); } else { fistN = new DefaultMutableTreeNode(p.getFio().getFirstName()); treeModel.insertNodeInto(fistN, midlN, midlN.getChildCount()); } } else { midlN = new DefaultMutableTreeNode(p.getFio().getMidllName()); fistN = new DefaultMutableTreeNode(p.getFio().getFirstName()); treeModel.insertNodeInto(midlN, lastN, lastN.getChildCount()); treeModel.insertNodeInto(fistN, midlN, midlN.getChildCount()); } } else { lastN = new DefaultMutableTreeNode(p.getFio().getLastName()); midlN = new DefaultMutableTreeNode(p.getFio().getMidllName()); fistN = new DefaultMutableTreeNode(p.getFio().getFirstName()); treeModel.insertNodeInto(lastN, root, root.getChildCount()); treeModel.insertNodeInto(midlN, lastN, lastN.getChildCount()); treeModel.insertNodeInto(fistN, midlN, midlN.getChildCount()); } TreePath path = new TreePath(treeModel.getPathToRoot(fistN)); System.out.println("path = " + path); } }
public static String[] genFamMenu(ArrayList<Family> source) { String[] menu = new String[source.size()]; Iterator famIter = source.iterator(); String dad, mom, item; Family fam; int ndex = 0; while (famIter.hasNext()) { fam = (Family) famIter.next(); dad = "Anonymous"; mom = "Anonymous"; if (fam.husband != null) { dad = fam.husband.name; } if (fam.wife != null) { mom = fam.wife.name; } item = dad + " & " + mom + " (" + fam.serialNmbr + ")"; if (fam.deleted) { item += " DELETED"; } menu[ndex++] = item; } return menu; } // end of method genFamMenu(source)
private void addPlateType() { platetypeList = Collector.getAllLinksOf(ObjType.PLATE_TYPE); Iterator i = platetypeList.iterator(); while (i.hasNext()) this.jComboBoxPlateType.addItem(i.next()); }
private void addAuthor() { authorList = Collector.getAllLinksOf(ObjType.PERSON); Iterator i = authorList.iterator(); while (i.hasNext()) this.jComboBoxAuthor.addItem(i.next()); }
private void btnModificarConstruccion_actionPerformed(ActionEvent e) { // Con esta opción modificamos los datos de la subparcela // En la variable ID tenemos el identificador de la subparcela // Creamos un ArrayList con los datos recogidos del formulario en el mismo orden que la base de // datos ArrayList UC = new ArrayList(); ArrayList UCTipo = new ArrayList(); ArrayList Checks = new ArrayList(); Checks.add(chkIndicador_Local_Interior); Checks.add(chkviviendacons); UC.add(ID_Construccion); UCTipo.add("1"); UC.add(txtcargocons.getText()); UCTipo.add("0"); UC.add(txtBloque.getText()); UCTipo.add("1"); UC.add(txtEscalera.getText()); UCTipo.add("1"); UC.add(txtPlanta.getText()); UCTipo.add("1"); UC.add(txtPuerta.getText()); UCTipo.add("1"); UC.add(txtdestinocons.getText()); UCTipo.add("1"); UC.add(cmbreformacons.getSelectedItem()); UCTipo.add("1"); UC.add(txtannoreforma.getText()); UCTipo.add("0"); UC.add(txtSuperficie_Total_Local.getText()); UCTipo.add("0"); UC.add(txtSuperficie_Terrazas_Local.getText()); UCTipo.add("0"); UC.add(txtSuperficie_Imputable_Local.getText()); UCTipo.add("0"); UC.add(txttipologiacons.getText()); UCTipo.add("1"); UC.add(cmbusocons.getSelectedItem().toString().substring(0, 1)); UCTipo.add("1"); UC.add(txtcategoriacons.getText()); UCTipo.add("1"); // Calculamos el reparto String Reparto = cmbreparto1cons.getSelectedItem().toString().substring(0, 1); Reparto = Reparto + cmbreparto2cons.getSelectedItem().toString().substring(0, 1); Reparto = Reparto + cmbreparto3cons.getSelectedItem().toString().substring(0, 1); System.out.println(Reparto); UC.add(Reparto); UCTipo.add("1"); UC.add(cmbtipovalorcons.getSelectedItem()); UCTipo.add("1"); UC.add(txtapreciacioncons.getText()); UCTipo.add("0"); if (alta == true) { UC.add("A"); UCTipo.add("1"); } else { UC.add("M"); UCTipo.add("1"); } UC.add(txtannoexpcons.getText()); UCTipo.add("0"); UC.add(txtreferenciacons.getText()); UCTipo.add("1"); Iterator CheckIt = Checks.iterator(); while (CheckIt.hasNext()) { if (((JCheckBox) CheckIt.next()).isSelected() == true) { UC.add("TRUE"); } else { UC.add("FALSE"); } UCTipo.add("1"); } // Actualizamos la información almacenada CatastroActualizarPostgre ActualizarConstruccion = new CatastroActualizarPostgre(); if (alta == false) { String Result = ActualizarConstruccion.ActualizarConstruccion(ID_Construccion, UC, UCTipo); System.out.println(Result); } else { String Result = ActualizarConstruccion.AltaConstruccion( ID_Parcela, txtcargocons.getText(), ID_Unidad, UC, UCTipo); System.out.println(Result); alta = false; } }
// =========================================================================/ protected void fireChanges() { if (listeners == null) return; Iterator it = listeners.iterator(); while (it.hasNext()) ((DMoteModelListener) (it.next())).shapeChanged(this, ANY); }
public void dataUpdate() { // 日付関係はUGUIUpdateManager経由で取得するように変更. int date = UGUIUpdateManager.getDate(); int boardNo = UGUIUpdateManager.getBoard(); int step = UGUIUpdateManager.getStep(); int now = UGUIUpdateManager.getMarketStatus(); if (now != fCurrentStatus) { fIsUpdated = true; } if (step <= fCurrentStep) { // Exchange X-Y がセットされている場合の処理.フラグ処理はあまりきれいではないが // X-Y の入れ換え自体が???なので勘弁してもらおう. if (fIsUpdated == false) { return; } else { fIsUpdated = false; } } if (boardNo == 1) { fDay.setText(String.valueOf(date - 1)); fBoard.setText(String.valueOf(fParam.getBoardPerDay())); } else { fDay.setText(String.valueOf(date)); if (now == fCurrentStatus) { fBoard.setText(String.valueOf(boardNo - 1)); } else { fBoard.setText(String.valueOf(boardNo)); } } fCurrentStep = step; fCurrentStatus = now; UCBoardDataCore cBoardData = (UCBoardDataCore) fCProtocol.getCommand(UCBoardDataCore.CMD_NAME); UCommandStatus status = cBoardData.doIt(); ArrayList array; HashMap boardDataInfo; long maxPrice, minPrice, totalBuyVolume; Vector printData = new Vector(); if (status.getStatus()) { array = cBoardData.getBoardDataArray(); boardDataInfo = cBoardData.getBoardDataInfo(); maxPrice = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_MAX_PRICE)).longValue(); minPrice = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_MIN_PRICE)).longValue(); totalBuyVolume = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_TOTAL_BUY_VOLUME)).longValue(); if (fIsExchangeXY == false) { fBoardGraph.setFixedMaxX(maxPrice); fBoardGraph.setFixedMinX(minPrice); fBoardGraph.setFixedMaxY(totalBuyVolume); fBoardGraph.setFixedMinY(0); } else { fBoardGraph.setFixedMaxX(totalBuyVolume); fBoardGraph.setFixedMinX(0); fBoardGraph.setFixedMaxY(maxPrice); fBoardGraph.setFixedMinY(minPrice); } } else { return; } long contractPrice = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_CONTRACT_PRICE)).longValue(); long contractVolume = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_CONTRACT_VOLUME)).longValue(); fContractPriceTextField.setText(String.valueOf(contractPrice)); fContractVolumeTextField.setText(String.valueOf(contractVolume)); ArrayList tmpSellData = new ArrayList(); ArrayList tmpBuyData = new ArrayList(); ArrayList tmpContractData = new ArrayList(); if (fIsExchangeXY == false) { tmpContractData.add(new Point2D.Double(minPrice, contractVolume)); tmpContractData.add(new Point2D.Double(contractPrice, contractVolume)); tmpContractData.add(new Point2D.Double(contractPrice, 0)); fBoardGraph.setXLableName("price"); fBoardGraph.setYLableName("volume"); } else { tmpContractData.add(new Point2D.Double(contractVolume, minPrice)); tmpContractData.add(new Point2D.Double(contractVolume, contractPrice)); tmpContractData.add(new Point2D.Double(0, contractPrice)); fBoardGraph.setXLableName("volume"); fBoardGraph.setYLableName("price"); } Iterator iter = array.iterator(); double tmpPrice, tmpVolume, currentSellVolume = 0, currentBuyVolume = totalBuyVolume; while (iter.hasNext()) { HashMap os = (HashMap) iter.next(); String s = (String) os.get(UCBoardDataCore.STRING_SELL_BUY); if (s.equals("sell")) { tmpPrice = ((Long) os.get(UCBoardDataCore.LONG_PRICE)).doubleValue(); tmpVolume = ((Long) os.get(UCBoardDataCore.LONG_VOLUME)).doubleValue(); if (fIsExchangeXY == false) { tmpSellData.add(new Point2D.Double(tmpPrice, currentSellVolume)); tmpSellData.add(new Point2D.Double(tmpPrice, currentSellVolume + tmpVolume)); } else { tmpSellData.add(new Point2D.Double(currentSellVolume, tmpPrice)); tmpSellData.add(new Point2D.Double(currentSellVolume + tmpVolume, tmpPrice)); } currentSellVolume += tmpVolume; } else if (s.equals("buy")) { tmpPrice = ((Long) os.get(UCBoardDataCore.LONG_PRICE)).doubleValue(); tmpVolume = ((Long) os.get(UCBoardDataCore.LONG_VOLUME)).doubleValue(); if (fIsExchangeXY == false) { tmpBuyData.add(new Point2D.Double(tmpPrice, currentBuyVolume)); tmpBuyData.add(new Point2D.Double(tmpPrice, currentBuyVolume - tmpVolume)); } else { tmpBuyData.add(new Point2D.Double(currentBuyVolume, tmpPrice)); tmpBuyData.add(new Point2D.Double(currentBuyVolume - tmpVolume, tmpPrice)); } currentBuyVolume -= tmpVolume; } } ((UGraphData) fBoardGraph.getGraph().get(0)).setData(tmpSellData); ((UGraphData) fBoardGraph.getGraph().get(1)).setData(tmpBuyData); }
/** Implementation de l'interface Iterable<Shape> */ public Iterator<Shape> iterator() { return shapes.iterator(); }
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(); } } }