@Override public void endElement(String uri, String localName, String qName) throws SAXException { if ("element".equals(qName)) { //$NON-NLS-1$ increment++; LayoutConstraints c = new LayoutConstraints(type, increment, x, y, width, height, weightx, weighty, position, expand); c.setColor(color); constraints.put(c, null); name.setLength(0); tag = -1; } }
public GridBagLayoutModel(GridBagLayoutModel layoutModel) { this.title = layoutModel.title; this.id = layoutModel.id; this.icon = layoutModel.icon; this.constraints = new LinkedHashMap<>(layoutModel.constraints.size()); Iterator<LayoutConstraints> enumVal = layoutModel.constraints.keySet().iterator(); while (enumVal.hasNext()) { this.constraints.put(enumVal.next().copy(), null); } }
public static int getViewTypeNumber(GridBagLayoutModel layout, Class<?> defaultClass) { int val = 0; if (layout != null && defaultClass != null) { Iterator<LayoutConstraints> enumVal = layout.getConstraints().keySet().iterator(); while (enumVal.hasNext()) { try { Class<?> clazz = Class.forName(enumVal.next().getType()); if (defaultClass.isAssignableFrom(clazz)) { val++; } } catch (Exception e) { LOGGER.error("Checking view", e); //$NON-NLS-1$ } } } return val; }
@Override public LayoutConstraints copy() { return new LayoutConstraints(this); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g; g2d.setColor(background); g2d.fillRect(x, y, getIconWidth(), getIconHeight()); g2d.setColor(Color.WHITE); Dimension dim = getGridSize(); double stepX = getIconWidth() / dim.getWidth(); double stepY = getIconHeight() / dim.getHeight(); Iterator<LayoutConstraints> enumVal = constraints.keySet().iterator(); while (enumVal.hasNext()) { LayoutConstraints l = enumVal.next(); Rectangle2D rect = new Rectangle2D.Double(x + l.gridx * stepX, y + l.gridy * stepY, l.gridwidth * stepX, l.gridheight * stepY); Color color = l.getColor(); if (color != null) { g2d.setColor(color); g2d.fill(rect); g2d.setColor(Color.WHITE); } g2d.draw(rect); } }
public static int getViewTypeNumber(GridBagLayoutModel layout, Class<?> defaultClass) { int val = 0; if (layout != null && defaultClass != null) { Iterator<LayoutConstraints> enumVal = layout.getConstraints().keySet().iterator(); while (enumVal.hasNext()) { try { Class<?> clazz = Class.forName(enumVal.next().getType()); if (defaultClass.isAssignableFrom(clazz)) { val++; } } catch (Exception e) { LOGGER.error("Checking view type", e); //$NON-NLS-1$ } } } return val; }
public GridBagLayoutModel(String id, String title, int rows, int cols, String defaultClass) { this.title = title; this.id = id; this.constraints = new LinkedHashMap<>(cols * rows); double weightx = 1.0 / cols; double weighty = 1.0 / rows; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { constraints.put(new LayoutConstraints(defaultClass, y * cols + cols, x, y, 1, 1, weightx, weighty, GridBagConstraints.CENTER, GridBagConstraints.BOTH), null); } } this.icon = buildIcon(); }
while (enumVal.hasNext()) { LayoutConstraints e = enumVal.next(); boolean typeView2d = isViewType(view2dClass, e.getType()); if (typeView2d) { ViewCanvas<E> oldView; if (oldViews.isEmpty()) { oldView = createDefaultView(e.getType()); oldView.registerDefaultListeners(); } else { Component component = createUIcomponent(e.getType()); if (component != null) { if (component instanceof JComponent) {
public DragLayoutElement(LayoutConstraints constraints, Component component) { if (constraints == null || component == null) { throw new IllegalArgumentException("Arguments cannot be null"); //$NON-NLS-1$ } this.constraints = constraints; this.originalConstraints = constraints.copy(); this.component = component; this.originalBound = component.getBounds(); }
private void adaptLayoutModel(ViewCanvas<E> viewCanvas) { final Map<LayoutConstraints, Component> map = new LinkedHashMap<>(1); this.layoutModel = new GridBagLayoutModel(map, "exp_tmp", ""); //$NON-NLS-1$ //$NON-NLS-2$ ExportImage<E> export = new ExportImage<>(viewCanvas); export.getInfoLayer().setBorder(3); LayoutConstraints e = new LayoutConstraints(viewCanvas.getClass().getName(), 0, 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH); map.put(e, export); grid.add(export, e); grid.revalidate(); }
private void adaptLayoutModel(GridBagLayoutModel layoutModel) { final Map<LayoutConstraints, Component> oldMap = layoutModel.getConstraints(); final Map<LayoutConstraints, Component> map = new LinkedHashMap<>(oldMap.size()); this.layoutModel = new GridBagLayoutModel(map, "exp_tmp", ""); //$NON-NLS-1$ //$NON-NLS-2$ Iterator<LayoutConstraints> enumVal = oldMap.keySet().iterator(); while (enumVal.hasNext()) { LayoutConstraints e = enumVal.next(); Component v = oldMap.get(e); LayoutConstraints constraint = e.copy(); if (v instanceof ViewCanvas) { ExportImage<?> export = new ExportImage<>((ViewCanvas) v); export.getInfoLayer().setBorder(3); map.put(constraint, export); v = export; } else { // Non printable component. Create a new empty panel to not steel the component from the original UI v = new JPanel(); map.put(constraint, v); } grid.add(v, e); } grid.revalidate(); }
Entry<LayoutConstraints, Component> entry = enumVal.next(); if (entry.getValue().equals(defaultView2d.getJComponent())) { GridBagConstraints c = entry.getKey().copy(); c.weightx = 1.0; c.weighty = 1.0;