/** * Given corner should be fully linked into the network. Needs to be removed as it connects two * parallel faces. We remove toAdd.nextL */ private void removeCorner(Corner toAdd) { if (holdRemoves) { removes.add(toAdd); return; } // update corners toAdd.prevC.nextC = toAdd.nextC; toAdd.nextC.prevC = toAdd.prevC; // update edges toAdd.nextC.prevL = toAdd.prevL; // update main corner list skel.liveCorners.remove(toAdd); // brute force search for all references to old edge (if this was on a // per face basis it'd be much nicer) for (Corner lc : skel.liveCorners) { if (lc.nextL == toAdd.nextL) { lc.nextL = toAdd.prevL; } if (lc.prevL == toAdd.nextL) { lc.prevL = toAdd.prevL; } } if (toAdd.prevL != toAdd.nextL) { // update live edge list skel.liveEdges.remove(toAdd.nextL); // update output edge list (the two input edges give one output // face) // skel.inputEdges.remove(toAdd.nextL); // update edges's live corners for (Corner c : toAdd.nextL.currentCorners) if (toAdd.prevL.currentCorners.add(c)) ; // also adds toAdd.nextC // merge output corner lists // add to the results map likewise skel.output.merge(toAdd.prevC, toAdd); // toAdd.prevL.addOutputSidesFrom // (toAdd.nextL); // all collisions need recalculation. This situation could be // avoided if collisions occur strictly with infinite faces. // recurse through all consecutive colinear faces...? skel.refindAllFaceEventsLater(); } // update edges's live corners (might have copied this over from nextL) toAdd.prevL.currentCorners.remove(toAdd); // todo: we've merged two machines! (pick an arbitrary one?) // assert ( toAdd.prevL.machine == toAdd.nextL.machine ); }
public void mouseMove(MouseEvent e) { if (started) { Rectangle size = glEditor.getCanvasClientArea(); double px2gl = glEditor.px2gl(size); corner.setX(corner.getX() + (double) (e.x - startX) * px2gl); corner.setY(corner.getY() - (double) (e.y - startY) * px2gl); glEditor.doRefresh(); } startX = e.x; startY = e.y; started = true; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Gives CubieCube representation of a faceletcube CubieCube toCubieCube() { byte ori; CubieCube ccRet = new CubieCube(); for (int i = 0; i < 8; i++) ccRet.cp[i] = URF; // invalidate corners for (int i = 0; i < 12; i++) ccRet.ep[i] = UR; // and edges Color col1, col2; for (Corner i : Corner.values()) { // get the colors of the cubie at corner i, starting with U/D for (ori = 0; ori < 3; ori++) if (f[cornerFacelet[i.ordinal()][ori].ordinal()] == U || f[cornerFacelet[i.ordinal()][ori].ordinal()] == D) break; col1 = f[cornerFacelet[i.ordinal()][(ori + 1) % 3].ordinal()]; col2 = f[cornerFacelet[i.ordinal()][(ori + 2) % 3].ordinal()]; for (Corner j : Corner.values()) { if (col1 == cornerColor[j.ordinal()][1] && col2 == cornerColor[j.ordinal()][2]) { // in cornerposition i we have cornercubie j ccRet.cp[i.ordinal()] = j; ccRet.co[i.ordinal()] = (byte) (ori % 3); break; } } } for (Edge i : Edge.values()) for (Edge j : Edge.values()) { if (f[edgeFacelet[i.ordinal()][0].ordinal()] == edgeColor[j.ordinal()][0] && f[edgeFacelet[i.ordinal()][1].ordinal()] == edgeColor[j.ordinal()][1]) { ccRet.ep[i.ordinal()] = j; ccRet.eo[i.ordinal()] = 0; break; } if (f[edgeFacelet[i.ordinal()][0].ordinal()] == edgeColor[j.ordinal()][1] && f[edgeFacelet[i.ordinal()][1].ordinal()] == edgeColor[j.ordinal()][0]) { ccRet.ep[i.ordinal()] = j; ccRet.eo[i.ordinal()] = 1; break; } } return ccRet; };
private void createGUI() { // set table and column renderers dataTable.setDefaultRenderer(Object.class, new MyCellRenderer()); columnHeader = new MyColumnHeaderRenderer(); columnHeader.setPreferredSize( new Dimension(preferredColumnWidth, SpreadsheetSettings.TABLE_CELL_HEIGHT)); for (int i = 0; i < dataTable.getColumnCount(); ++i) { dataTable.getColumnModel().getColumn(i).setHeaderRenderer(columnHeader); dataTable.getColumnModel().getColumn(i).setPreferredWidth(preferredColumnWidth); } // disable row selection (for now) dataTable.setColumnSelectionAllowed(false); dataTable.setRowSelectionAllowed(false); // dataTable.setAutoResizeMode(JTable.); dataTable.setPreferredScrollableViewportSize(dataTable.getPreferredSize()); dataTable.setMinimumSize(new Dimension(100, 50)); // dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); dataTable.setAutoCreateColumnsFromModel(false); dataTable.setGridColor(TABLE_GRID_COLOR); // create a scrollPane for the table scrollPane = new JScrollPane(dataTable); scrollPane.setBorder(BorderFactory.createEmptyBorder()); // create row header rowHeader = new MyRowHeader(this, dataTable); scrollPane.setRowHeaderView(rowHeader); // create enableAll button and put it in the upper left corner CheckBoxIcon cbIcon = new CheckBoxIcon(13); ImageIcon iconUnChecked = cbIcon.createCheckBoxImageIcon(false, false); ImageIcon iconChecked = cbIcon.createCheckBoxImageIcon(true, false); btnEnableAll = new JButton(); btnEnableAll.setIcon(iconUnChecked); btnEnableAll.setDisabledIcon(iconChecked); btnEnableAll.setEnabled(false); btnEnableAll.setBorderPainted(false); btnEnableAll.setBackground( geogebra.awt.Color.getAwtColor(GeoGebraColorConstants.TABLE_BACKGROUND_COLOR_HEADER)); btnEnableAll.setContentAreaFilled(false); btnEnableAll.setHorizontalAlignment(SwingConstants.LEFT); btnEnableAll.addActionListener(this); Corner upperLeftCorner = new Corner(); upperLeftCorner.setLayout(new BorderLayout()); upperLeftCorner.add(btnEnableAll, BorderLayout.WEST); upperLeftCorner.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 1, TABLE_GRID_COLOR), BorderFactory.createEmptyBorder(0, 5, 0, 2))); // set the other corners scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, upperLeftCorner); scrollPane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, new Corner()); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, new Corner()); lblHeader = new JLabel(); lblHeader.setHorizontalAlignment(JLabel.LEFT); lblHeader.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(2, 5, 2, 2))); // finally, load up our JPanel this.setLayout(new BorderLayout()); this.add(lblHeader, BorderLayout.NORTH); this.add(scrollPane, BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); this.setMinimumSize(dataTable.getPreferredSize()); }