/** * Construit et initialise le groupe. */ public BGroupeVolume() { switch_ = new Switch(Switch.CHILD_MASK); switch_.setCapability(Group.ALLOW_CHILDREN_EXTEND); switch_.setCapability(Group.ALLOW_CHILDREN_READ); switch_.setCapability(Group.ALLOW_CHILDREN_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_READ); switch_.setCapability(ALLOW_DETACH); tg_.addChild(switch_); }
/** * Affiche tous les objets. */ public void setAllVisible() { final int nb = switch_.numChildren(); final BitSet bs = new BitSet(); for (int i = 0; i < nb; i++) { bs.set(i); } switch_.setChildMask(bs); }
/** * @return tous les enfants du groupe (descend tous les niveaux) */ public List getTousEnfants() { final Vector v = new Vector(); final Enumeration enfants = switch_.getAllChildren(); for (final Enumeration e = enfants; e.hasMoreElements();) { final Object element = e.nextElement(); if (element instanceof BVolume) { v.addElement(element); } else if (element instanceof BGroupeVolume) { v.addAll(((BGroupeVolume) element).getTousEnfants()); } } return v; }
/** * rend un objet du groupe visible ou pas. */ public void changeVisible(final int _index, final boolean _b) { final BitSet bs = switch_.getChildMask(); bs.set(_index, _b); switch_.setChildMask(bs); }
shapeGroup.setCapability(BranchGroup.ALLOW_DETACH); switchGroup = new Switch(Switch.CHILD_MASK); switchGroup.setCapability(Switch.ALLOW_SWITCH_WRITE); switchGroup.setCapability(Switch.ENABLE_PICK_REPORTING); switchGroup.setCapability(Switch.ALLOW_CHILDREN_EXTEND); switchGroup.setCapability(Switch.ALLOW_CHILDREN_READ); switchGroup.setCapability(Switch.ALLOW_CHILDREN_WRITE); switchGroup.setCapability(BranchGroup.ALLOW_DETACH); switchGroup.addChild(g); new java.util.BitSet(switchGroup.numChildren()); frameSlider.setMaximum(switchGroup.numChildren() - 1); frameSlider.setEnabled(true);
switch_ = new Switch(Switch.CHILD_MASK); switch_.setCapability(Group.ALLOW_CHILDREN_EXTEND); switch_.setCapability(Group.ALLOW_CHILDREN_READ); switch_.setCapability(Group.ALLOW_CHILDREN_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_WRITE); switch_.setCapability(Switch.ALLOW_SWITCH_READ); tg_.addChild(switch_); shape_ = new Shape3D(); shape_.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ); shape_.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE); switch_.addChild(shape_); final ColoringAttributes ca = new ColoringAttributes(); ca.setCapability(ColoringAttributes.ALLOW_COLOR_READ);
switch_.addChild(btg);
/** * Supprime l'objet du groupe. * * @param index:l'index de l'objet */ public void remove(final int _index) { switch_.removeChild(_index); final List enfants = getTousEnfants(); for (int i = _index; i < getNumChildren(); i++) { final Objet3DInterface o = (Objet3DInterface) enfants.get(i); o.setIndex(i); } final BitSet bs = switch_.getChildMask(); for (int i = _index + 1; i < bs.length(); i++) { if (bs.get(i)) { bs.set(i - 1); } } switch_.setChildMask(bs); }
/** * ajoute un objet au groupe. * * @param _objet l'objet ajouter */ public void add(final Objet3DInterface _objet) { if (_objet instanceof BVolume) { final BVolume volume = (BVolume) _objet; if (!volume.isCompiled()) { volume.compile(); } switch_.addChild(volume); volume.setIndex(switch_.numChildren() - 1); volume.setPere(this); setBoite(getBoite()); } }
/** * affichage plein ou seulement boite englobante. * * @param _rapide : vrai->boite;faux->plein */ public void setRapide(final boolean _rapide) { rapide_ = _rapide; if (isRapide()) { final BitSet bs = new BitSet(); bs.clear(0); bs.set(1); switch_.setChildMask(bs); } else { final BitSet bs = new BitSet(); bs.clear(1); bs.set(0); switch_.setChildMask(bs); } }
public void detach() { switch_.removeAllChildren(); boiteEnglobante_.removeAllChildren(); super.detach(); }
switchGroup = new Switch(Switch.CHILD_MASK); switchGroup.setCapability(Switch.ALLOW_SWITCH_WRITE); switchGroup.setCapability(Switch.ENABLE_PICK_REPORTING); switchGroup.setCapability(Switch.ALLOW_CHILDREN_EXTEND); switchGroup.setCapability(Switch.ALLOW_CHILDREN_READ); switchGroup.setCapability(Switch.ALLOW_CHILDREN_WRITE); switchGroup.setCapability(BranchGroup.ALLOW_DETACH); shapeGroups[i].setCapability(BranchGroup.ALLOW_DETACH); switchGroup.addChild(shapeGroups[i]); = new java.util.BitSet(switchGroup.numChildren());
bTg.setTransform(t3d); bTg.addChild(boiteEnglobante_); switch_.addChild(bTg);
/** * Views the current frame. */ private void viewCurrentFrame() { if (visibleFrames != null && switchGroup != null) { frameSlider.setValue(currentFrame); visibleFrames.set(previousFrame, false); visibleFrames.set(currentFrame, true); switchGroup.setChildMask(visibleFrames); } previousFrame = currentFrame; if (isPlaying()) { notifyListeners(canvas); } }
public void detach() { super.detach(); bbox_.setLower(null); bbox_.setUpper(null); shape_.getAppearance().setMaterial(null); shape_.setAppearance(null); shape_.removeAllGeometries(); switch_.removeAllChildren(); }
bTg.setTransform(t3d); bTg.addChild(boiteEnglobante_); switch_.addChild(bTg);
private void clearView() { if (!VGraphicsUtil.NO_3D) { if (isDoEmpty()) { if (visibleNodes != null) { visibleNodes.set(0, false); visibleNodes.set(1, false); switchGroup.setChildMask(visibleNodes); for (int i = 0; i < shapeParents.length; i++) { if (shapeParents[i] != null) { shapeParents[i].detach(); shapeParents[i] = null; } } if (getCanvas() != null) { getCanvas().contentChanged(); getCanvas().postRenderTask(); } } } } }
/** * Renvoie la boite englobant tous les objets du groupe. */ public GrBoite getBoite() { GrBoite boite = null; final GrBoite tmp = new GrBoite(); // =new GrBoite(); // boite.ajuste(new GrPoint()); final Enumeration enfants = switch_.getAllChildren(); for (final Enumeration e = enfants; e.hasMoreElements();) { final Object element = e.nextElement(); if (element instanceof BVolume) { final BVolume volume = ((BVolume) element); if (volume.getBoite(tmp) != null) { if (boite == null) { boite = new GrBoite(tmp); } else { boite.ajuste(tmp); } } // if (element instanceof BGroupeVolume) boite=boite.union(((BGroupeVolume)element).getBoite()); } } return boite; }
bTg.setTransform(t3d); bTg.addChild(boiteEnglobante_); switch_.addChild(bTg);
visibleNodes.set(1, true); visibleNodes.set(0, false); switchGroup.setChildMask(visibleNodes); visibleNodes.set(0, true); visibleNodes.set(1, false); switchGroup.setChildMask(visibleNodes);