public void load() { attributes = getAttributes(); attributes.set("size", 3); // attributes.set("shift", 0); // attributes.set("circlesDistance", 0); performanceMeter = new MarvinPerformanceMeter(); }
/** * @param plgComp - graphical component; * @return the value associated with the specified component */ public Object getValue(MarvinPluginWindowComponent plgComp) { String l_id = plgComp.getAttributeID(); MarvinAttributes attr = plgComp.getAttributes(); JComponent comp = plgComp.getComponent(); switch (plgComp.getType()) { case COMPONENT_TEXTFIELD: return stringToType(((JTextField) comp).getText(), attr.get(l_id)); case COMPONENT_COMBOBOX: return (((JComboBox) comp).getSelectedItem()); case COMPONENT_SLIDER: return (((JSlider) comp).getValue()); case COMPONENT_TEXTAREA: return (((JTextArea) comp).getText()); case COMPONENT_CHECKBOX: return (((JCheckBox) comp).isSelected()); case COMPONENT_MATRIX_PANEL: return (((MarvinMatrixPanel) comp).getValue()); } return null; }
/** * @param id - component id. * @param attrID - attribute id. * @param lines - number of lines. * @param columns - number of columns. * @param attr - MarivnAttributes Object. */ public void addTextArea(String id, String attrID, int lines, int columns, MarvinAttributes attr) { JComponent comp = new JTextArea(lines, columns); JScrollPane scrollPanel = new JScrollPane(comp); ((JTextArea) (comp)).setText(attr.get(attrID).toString()); // plug manually panelCurrent.add(scrollPanel); // box.add(l_scrollPane); hashComponents.put( id, new MarvinPluginWindowComponent(id, attrID, attr, comp, ComponentType.COMPONENT_TEXTAREA)); // plugComponent(id, l_scrollPane, attrID, a_attributes, ComponentType.COMPONENT_TEXTAREA); }
private static MarvinImage showCorners(MarvinImage image, MarvinAttributes attr, int rectSize) { MarvinImage ret = image.clone(); int[][] cornernessMap = (int[][]) attr.get("cornernessMap"); int rsize = 0; for (int x = 0; x < cornernessMap.length; x++) { for (int y = 0; y < cornernessMap[0].length; y++) { // Is it a corner? if (cornernessMap[x][y] > 0) { rsize = Math.min( Math.min(Math.min(x, rectSize), Math.min(cornernessMap.length - x, rectSize)), Math.min(Math.min(y, rectSize), Math.min(cornernessMap[0].length - y, rectSize))); ret.fillRect(x, y, rsize, rsize, Color.red); } } } return ret; }
/** * @param a_attrName atribute´s name * @return the attribute´s value */ public Object getAttribute(String label) { return marvinAttributes.get(label); }
/** Set a list of attributes. Format: (String)name, (Object)value... */ public void setAttributes(Object... params) { marvinAttributes.set(params); }
/** * Set an attribute * * @param a_attrName attribute´s name * @param value attribute´s value */ public void setAttribute(String label, Object value) { marvinAttributes.set(label, value); }
/** * Check if two attributes are equal. * * @param attrA MarvinAttribute to be compared. * @param attrB MarvinAttribute to be compared. */ public void assertEquals(MarvinAttributes attrA, MarvinAttributes attrB) { if (!Arrays.equals(attrA.getValues(), attrB.getValues())) { fail(ATTRIBUTES_NOT_EQUAL); } }
public void process( MarvinImage a_imageIn, MarvinImage a_imageOut, MarvinAttributes a_attributesOut, MarvinImageMask a_mask, boolean a_previewMode) { performanceMeter.start("Moda Filter"); int l_size = (Integer) attributes.get("size"); int mapSize = l_size * l_size; int l_totalRed = 0; int l_totalGreen = 0; int l_totalBlue = 0; int qtd = 0; int tmpx = 0; int tmpy = 0; int width = a_imageIn.getWidth(); int height = a_imageIn.getHeight(); Map<Integer, Integer> mapModaR; Map<Integer, Integer> mapModaG; Map<Integer, Integer> mapModaB; performanceMeter.enableProgressBar("Moda Filter", a_imageIn.getWidth() * a_imageIn.getHeight()); performanceMeter.startEvent("Moda Filter"); boolean[][] l_arrMask = a_mask.getMask(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (l_arrMask != null && !l_arrMask[x][y]) { continue; } tmpx = x - l_size; tmpy = y - l_size; mapModaR = new HashMap<Integer, Integer>(mapSize); mapModaG = new HashMap<Integer, Integer>(mapSize); mapModaB = new HashMap<Integer, Integer>(mapSize); if (tmpx < 0) tmpx = 0; if (tmpy < 0) tmpy = 0; int finalX = x + l_size; int finalY = y + l_size; if (finalX > width) finalX = width; if (finalY > height) finalY = height; for (int xm = tmpx; xm < finalX; xm++) { for (int ym = tmpy; ym < y + l_size; ym++) { if (xm >= 0 && xm < width && ym >= 0 && ym < height) { int rgb = a_imageIn.getIntColor(xm, ym); l_totalRed = (int) (rgb & 0x00FF0000) >>> 16; l_totalGreen = (int) ((rgb & 0x0000FF00) >>> 8); l_totalBlue = (int) (rgb & 0x000000FF); Integer l_val = mapModaR.get(l_totalRed); if (l_val == null) l_val = 0; mapModaR.put((Integer) l_totalRed, ++l_val); l_val = mapModaG.get(l_totalGreen); if (l_val == null) l_val = 0; mapModaG.put((Integer) l_totalGreen, ++l_val); l_val = mapModaB.get(l_totalBlue); if (l_val == null) l_val = 0; mapModaB.put((Integer) l_totalBlue, ++l_val); } } } Integer r1 = 0; for (Integer it : mapModaR.keySet()) { if (mapModaR.get(it) >= r1) { r1 = it; } } Integer g1 = 0; for (Integer it : mapModaG.keySet()) { if (mapModaG.get(it) >= g1) { g1 = it; } } Integer b1 = 0; for (Integer it : mapModaB.keySet()) { if (mapModaB.get(it) >= b1) { b1 = it; } } a_imageOut.setIntColor(x, y, a_imageIn.getAlphaComponent(x, y), r1, g1, b1); } performanceMeter.incProgressBar(height); performanceMeter.stepsFinished(height); } performanceMeter.finishEvent(); performanceMeter.finish(); }
/** * Adds TextField * * @param id component id. * @param attrID attribute id. * @param attr MarivnAttributes Object. */ public void addTextField(String id, String attrID, MarvinAttributes attr) { JComponent comp = new JTextField(5); ((JTextField) (comp)).setText(attr.get(attrID).toString()); plugComponent(id, comp, attrID, attr, ComponentType.COMPONENT_TEXTFIELD); }