List of usage examples for org.apache.commons.collections CollectionUtils size
public static int size(Object object)
From source file:org.goko.core.gcode.bean.provider.AbstractGCodeProvider.java
/** * Generate a line number for the given command * @param command the GCodeLine/*from w w w. j a v a 2s . c om*/ */ private void generateLineNumber(GCodeCommand command) { int lineNumber = CollectionUtils.size(mapCommandById) + 1; command.setLineNumber(lineNumber); }
From source file:org.goko.core.gcode.execution.ExecutionToken.java
/** (inheritDoc) * @see org.goko.core.gcode.execution.IExecutionToken#getLineCountByState(org.goko.core.gcode.execution.IExecutionTokenState) *///w ww . j a v a 2 s . c o m @Override public int getLineCountByState(T state) throws GkException { int result = 0; if (mapLineByExecutionState.containsKey(state)) { result = CollectionUtils.size(mapLineByExecutionState.get(state)); } return result; }
From source file:org.goko.core.gcode.execution.ExecutionToken.java
/** (inheritDoc) * @see org.goko.core.gcode.execution.IExecutionToken#reset() *///from www. ja v a 2 s. co m @Override public void reset() throws GkException { this.mapExecutionStateById = new HashMap<Integer, T>(); this.mapLineByExecutionState = new HashMap<T, List<Integer>>(); this.mapLineByExecutionState.put(initialState, new ArrayList<Integer>()); this.currentIndex = -1; this.setState(ExecutionState.IDLE); IGCodeProvider provider = getGCodeProvider(); this.lineCount = CollectionUtils.size(provider.getLines()); if (CollectionUtils.isNotEmpty(provider.getLines())) { for (GCodeLine gCodeLine : provider.getLines()) { this.mapLineByExecutionState.get(initialState).add(gCodeLine.getId()); this.mapExecutionStateById.put(gCodeLine.getId(), initialState); } } }
From source file:org.goko.core.gcode.rs274ngcv3.jogl.renderer.RS274GCodeRenderer.java
/** (inheritDoc) * @see org.goko.tools.viewer.jogl.utils.render.internal.AbstractVboJoglRenderer#buildGeometry() *//*from ww w . j a v a 2 s. c o m*/ @Override protected void buildGeometry() throws GkException { ArrayList<Point3d> lstVertices = new ArrayList<Point3d>(); ArrayList<Color4f> lstColors = new ArrayList<Color4f>(); mapVerticesGroupByIdLine = new HashMap<Integer, VerticesGroupByLine>(); GCodeContext context = new GCodeContext(gcodeContextProvider.getGCodeContext()); IGCodeProvider provider = Activator.getRS274NGCService().getGCodeProvider(idGCodeProvider); InstructionProvider instructionSet = Activator.getRS274NGCService().getInstructions(context, provider); IInstructionSetIterator<GCodeContext, AbstractInstruction> iterator = Activator.getRS274NGCService() .getIterator(instructionSet, context); IInstructionColorizer<GCodeContext, AbstractInstruction> colorizer = new MotionModeColorizer(); //IInstructionColorizer<GCodeContext, AbstractInstruction> colorizer = new SelectedPlaneColorizer(); //IInstructionColorizer<GCodeContext, AbstractInstruction> colorizer = new ArcAngleColorizer(); while (iterator.hasNext()) { GCodeContext preContext = new GCodeContext(iterator.getContext()); AbstractInstruction instruction = iterator.next(); // TEST : Make sure we have a complete start position for rendering. if (preContext.getX() != null && preContext.getY() != null && preContext.getZ() != null) { List<Point3d> vertices = InstructionGeometryFactory.build(preContext, instruction); addVerticesGroup(instruction.getIdGCodeLine(), lstVertices.size(), vertices); lstVertices.addAll(vertices); // Let's generate the colors and update the bounds as well Color4f color = colorizer.getColor(preContext, instruction); for (int i = 0; i < vertices.size(); i++) { lstColors.add(color); } } } setVerticesCount(CollectionUtils.size(lstVertices)); stateBuffer = IntBuffer.allocate(getVerticesCount()); stateBuffer.rewind(); setColorsBuffer(JoglUtils.buildFloatBuffer4f(lstColors)); setVerticesBuffer(JoglUtils.buildFloatBuffer3d(lstVertices)); }
From source file:org.goko.gcode.filesender.controller.GCodeFileSenderController.java
protected void parseFile() throws GkException { if (getDataModel().getGcodeProvider() != null) { workspaceService.deleteGCodeProvider(getDataModel().getGcodeProvider().getId()); }//w ww . ja va 2s. c o m GCodeContext currentContext = controllerService.getCurrentGCodeContext(); IGCodeProvider gcodeFile = gCodeService.parseFile(getDataModel().getFilePath(), currentContext); getDataModel().setGcodeProvider(gcodeFile); long seconds = (long) timeService.evaluateExecutionTime(gcodeFile); getDataModel().setTotalCommandCount(CollectionUtils.size(gcodeFile.getGCodeCommands())); getDataModel().setRemainingTime(getDurationAsString(seconds * 1000)); workspaceService.addGCodeProvider(gcodeFile); }
From source file:org.goko.grbl.controller.GrblControllerService.java
public void sendCommand(GCodeCommand command) throws GkException { List<Byte> byteCommand = GkUtils.toBytesList(getGCodeService().convert(command)); int usedBufferCount = CollectionUtils.size(byteCommand); communicator.send(byteCommand);//from w ww . ja v a 2 s . com setUsedGrblBuffer(usedGrblBuffer + usedBufferCount); }
From source file:org.goko.log.part.model.LogLevelNode.java
public void addMessage(ApplicativeLogEvent message) { while (CollectionUtils.size(this.messages) > maxSize) { this.messages.remove(maxSize); }// w ww . j a va 2 s . co m this.messages.add(message); }
From source file:org.goko.log.part.model.ProblemTreeLabelProvider.java
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element == null) { super.update(cell); return;/*from w w w . j a v a 2 s . co m*/ } JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, HYPERLINK_COLOR); StyledString styledString = new StyledString(); if (element instanceof LogLevelNode) { LogLevelNode logNode = (LogLevelNode) element; if (targetColumn == COLUMN_DESCRIPTION) { styledString.append(logNode.getLabel()); styledString.append(" (" + CollectionUtils.size(logNode.getMessages()) + ")", StyledString.COUNTER_STYLER); cell.setImage(getImage(element)); } } else if (element instanceof ApplicativeLogEvent) { ApplicativeLogEvent event = (ApplicativeLogEvent) element; if (targetColumn == COLUMN_DESCRIPTION) { styledString.append(event.getMessage()); } else if (targetColumn == COLUMN_SOURCE) { styledString.append(event.getSource()); } else if (targetColumn == COLUMN_DATE) { DateFormat df = new SimpleDateFormat("HH:mm:ss"); styledString.append(df.format(event.getDate())); } } else { styledString.append(String.valueOf(element)); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); super.update(cell); }
From source file:org.goko.serial.bindings.SerialConsoleController.java
public void selectPreviousCommandInHistory() { int index = getDataModel().getCommandHistoryIndex(); if (getDataModel().getCommandHistory().size() > 0) { if (index + 1 <= CollectionUtils.size(getDataModel().getCommandHistory())) { index = index + 1;/*from w ww . j a v a 2 s.co m*/ getDataModel().setCommandHistoryIndex(index); } //int reversedIndex = getDataModel().getCommandHistory().size() - index; index = Math.max(0, Math.min(index, getDataModel().getCommandHistory().size())); String cmd = getDataModel().getCommandHistory().get(getDataModel().getCommandHistory().size() - index); getDataModel().setCurrentCommand(cmd); } }
From source file:org.goko.tools.viewer.jogl.utils.render.basic.PolylineRenderer.java
/** (inheritDoc) * @see org.goko.tools.viewer.jogl.utils.render.internal.AbstractVboJoglRenderer#buildGeometry() *///from w w w. j a v a 2 s . c o m @Override protected void buildGeometry() throws GkException { if (closed) { setVerticesCount(CollectionUtils.size(points) + 1); } else { setVerticesCount(CollectionUtils.size(points)); } FloatBuffer vertices = FloatBuffer.allocate(getVerticesCount() * 4); FloatBuffer colors = FloatBuffer.allocate(getVerticesCount() * 4); if (CollectionUtils.isNotEmpty(points)) { for (Point3d p : points) { vertices.put(new float[] { (float) p.x, (float) p.y, (float) p.z, 1 }); colors.put(new float[] { color.x, color.y, color.z, color.w }); } if (closed) { Point3d p = points.get(0); vertices.put(new float[] { (float) p.x, (float) p.y, (float) p.z, 1 }); colors.put(new float[] { color.x, color.y, color.z, color.w }); } } vertices.rewind(); colors.rewind(); setVerticesBuffer(vertices); setColorsBuffer(colors); }