Logo Search packages:      
Sourcecode: latexdraw version File versions  Download package

void latexDraw::ui::LaTeXDrawFrame::updateFrameFields (  )  [inline]

Allows to update fields of the frame : if a figure is selected, its parameters are updated, else general parameters are used to set the fields.

Definition at line 1760 of file LaTeXDrawFrame.java.

References buttonBordersColor, buttonDbleBoundColor, buttonGradientEndC, buttonGradientStartC, buttonHatchColor, buttonInteriorColor, buttonShadowColor, latexDraw::figures::Figure::canBeFilled, latexDraw::figures::Figure::canBeHatched(), latexDraw::figures::Figure::canHaveArrow, latexDraw::figures::Figure::canHaveShadow, dbleBoundCheckBox, drawPanel, filledCheckBox, latexDraw::figures::properties::Arrowable::getArrow1Style(), latexDraw::figures::properties::Arrowable::getArrow2Style(), latexDraw::figures::Figure::getBordersPosition(), latexDraw::figures::Dot::getCurrentStyle(), latexDraw::figures::Figure::getDoubleColor(), latexDraw::ui::DrawPanel::getDraw(), latexDraw::figures::Draw::getFigureAt(), latexDraw::figures::Figure::getGradientEndColor(), latexDraw::figures::Figure::getGradientStartColor(), latexDraw::figures::Figure::getHatchingColor(), latexDraw::figures::Figure::getHatchingStyle(), latexDraw::figures::Figure::getInteriorColor(), latexDraw::figures::Figure::getLinesColor(), latexDraw::figures::Figure::getLineStyle(), latexDraw::ui::DrawContainer::getSelected(), latexDraw::figures::Figure::getShadowColor(), latexDraw::figures::Figure::getThickness(), latexDraw::figures::Dot::getWidth(), latexDraw::figures::Figure::hasDoubleBoundary, latexDraw::figures::Figure::hasGradient(), latexDraw::figures::Figure::hasShadow, latexDraw::figures::properties::Arrowable::hasTwoLeftArrows(), latexDraw::figures::Figure::isBordersMovable, latexDraw::figures::Figure::isDashableOrDotable, latexDraw::figures::Figure::isDoubleBoundaryable, latexDraw::figures::Figure::isFilled, latexDraw::figures::Figure::isHatched(), latexDraw::figures::Figure::isThicknessable, setBorderChoice(), latexDraw::ui::components::ColorButton::setColor(), setDotChoice(), setHatchChoice(), setLineArrowLChoice(), setLineArrowRChoice(), setLineChoice(), setThicknessFieldValue(), shadowCheckBox, latexDraw::figures::Draw::size(), and updateFillCB().

Referenced by setSelection().

      {     
            try
            {
                  Draw listSelected = drawPanel.getDraw().getSelected();
                  
                  if(listSelected!=null && listSelected.size()==1)
                  {
                        Figure f = listSelected.getFigureAt(0);
                        
                        if(f!=null)
                        {
                              if(f instanceof Dot)
                              {
                                    setDotFieldValue(((Dot)f).getWidth());
                                    setDotChoice(((Dot)f).getCurrentStyle());
                                    buttonInteriorColor.setVisible(f.canBeFilled());
                              }
                              else
                              {
                                    if(f.canHaveArrow())
                                    {
                                    setLineArrowLChoice(((Arrowable)f).getArrow1Style());
                                    setLineArrowRChoice(((Arrowable)f).hasTwoLeftArrows() ? 
                                                ArrowHead.invertArrowStyle(((Arrowable)f).getArrow2Style()) : ((Arrowable)f).getArrow2Style());
                                    }
                                    
                                    setThicknessFieldValue(f.getThickness()); 
                                    setLineChoice(f.getLineStyle());
                                    filledCheckBox.setSelected(f.canBeFilled() && f.isFilled());
                              }
                              
                              buttonBordersColor.setColor(f.getLinesColor());
                              setHatchChoice(f.getHatchingStyle());
                              dbleBoundCheckBox.setSelected(f.isDoubleBoundaryable() && f.hasDoubleBoundary());
                              shadowCheckBox.setSelected(f.hasShadow());
                              updateFillCB();
                              
                              if(f.canHaveShadow())
                                    buttonShadowColor.setColor(f.getShadowColor());
                              
                              if(f.canBeFilled())
                              {
                                    buttonBordersColor.setColor(f.getLinesColor());
                                    buttonInteriorColor.setColor(f.getInteriorColor());
                                    buttonGradientEndC.setColor(f.getGradientEndColor());
                                    buttonGradientStartC.setColor(f.getGradientStartColor());
                              }
                              
                              if(f.canBeHatched())
                                    buttonHatchColor.setColor(f.getHatchingColor());
                              
                              if(f.isDoubleBoundaryable())
                                    buttonDbleBoundColor.setColor(f.getDoubleColor());
                              
                              if(f.isBordersMovable())
                                    setBorderChoice(f.getBordersPosition());
                        }//if
                  }
                  else 
                        if(listSelected!=null && listSelected.size()>1)
                        {// We try to identify the figures' attributes that are equals.
                              boolean ok;
                              int i, size = listSelected.size();
                              Color linesC = listSelected.getFigureAt(0).getLinesColor();
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).isDoubleBoundaryable())
                                          ok = false;
                              
                              if(!ok)
                              {
                                    boolean hasDbleBound = listSelected.getFigureAt(i-1).hasDoubleBoundary();
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).isDoubleBoundaryable() && 
                                                listSelected.getFigureAt(i).hasDoubleBoundary()!=hasDbleBound)
                                                ok = false;
                                    
                                    dbleBoundCheckBox.setSelected(ok ? hasDbleBound : genHasDbleBord);
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).hasDoubleBoundary())
                                                ok = false;
                                    
                                    if(!ok)
                                    {
                                          Color dbleC = listSelected.getFigureAt(i-1).getDoubleColor();
                                          
                                          for(i=0, ok=true; i<size && ok; i++)
                                                if(listSelected.getFigureAt(i).hasDoubleBoundary() && 
                                                      !listSelected.getFigureAt(i).getDoubleColor().equals(dbleC))
                                                      ok = false;
                                          
                                          genDbleBordCB.setColor(ok ? dbleC : genDbleC);
                                    }
                                    else
                                          genDbleBordCB.setColor(genDbleC);
                              }
                              else
                                    dbleBoundCheckBox.setSelected(genHasDbleBord);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i) instanceof Arrowable)
                                          ok = false;
                              
                              if(!ok)
                              {
                                    Arrowable arr = ((Arrowable)listSelected.getFigureAt(i-1));
                                    String arrow1S = arr.getArrow1Style();
                                    String arrow2S = arr.hasTwoLeftArrows() ? ArrowHead.invertArrowStyle(arr.getArrow2Style()) : arr.getArrow2Style();
                                    boolean ok2 = true;
                                    String str;
                                    
                                    for(i=0, ok=true; i<size; i++)
                                          if(listSelected.getFigureAt(i) instanceof Arrowable)
                                          {
                                                Arrowable a = (Arrowable)listSelected.getFigureAt(i);
                                                str = a.getArrow2Style();
                                                
                                                if(a.hasTwoLeftArrows())
                                                      str = ArrowHead.invertArrowStyle(str);
                                                
                                                if(!a.getArrow1Style().equals(arrow1S))
                                                      ok = false;
                                                
                                                if(!str.equals(arrow2S))
                                                      ok2 = false;
                                          }
                                    
                                    setLineArrowLChoice(ok ? arrow1S : genLeftArrS);
                                    setLineArrowRChoice(ok2 ? arrow2S : genRightArrS);
                              }
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i) instanceof Dot)
                                          ok = false;
                        
                              if(!ok)
                              {
                                    String dotStyle = ((Dot)listSelected.getFigureAt(i-1)).getCurrentStyle();
                                    float width = ((Dot)listSelected.getFigureAt(i-1)).getWidth();
                                    boolean ok2 = true;
                                    
                                    for(i=0, ok=true; i<size; i++)
                                          if(listSelected.getFigureAt(i) instanceof Dot)
                                          {
                                                Dot d = (Dot)listSelected.getFigureAt(i);
                                                
                                                if(!d.getCurrentStyle().equals(dotStyle))
                                                      ok = false;
                                          
                                                if(d.getWidth()!=width)
                                                      ok2 = false;
                                          }
                                    
                                    setDotChoice(ok ? dotStyle : genDotS);
                                    setDotFieldValue(ok2 ? width : genDotSize);
                              }
                              else setLineChoice(genLineStyleS);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).isDashableOrDotable())
                                          ok = false;
                        
                              if(!ok)
                              {
                                    String lineStyle = listSelected.getFigureAt(i-1).getLineStyle();
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).isDashableOrDotable() && 
                                                !listSelected.getFigureAt(i).getLineStyle().equals(lineStyle))
                                                      ok = false;
                                    
                                    setLineChoice(ok ? lineStyle : genLineStyleS);
                              }
                              else setLineChoice(genLineStyleS);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).isBordersMovable())
                                          ok = false;
                              
                              if(!ok)
                              {
                                    String bordPos = listSelected.getFigureAt(i-1).getBordersPosition();
                              
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).isBordersMovable() && 
                                                !listSelected.getFigureAt(i).getBordersPosition().equals(bordPos))
                                                      ok = false;
                                    
                                    setBorderChoice(ok ? bordPos : genBordPosS);
                              }
                              else setBorderChoice(genBordPosS);
                              
                              for(i=1; i<size && ok; i++)
                                    if(!listSelected.getFigureAt(i).getLinesColor().equals(linesC))
                                          ok = false;
                              
                              genLineCB.setColor(ok ? linesC : genLineC);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).isThicknessable())
                                          ok = false;
                              
                              if(!ok)
                              {
                                    Float thickness = listSelected.getFigureAt(i-1).getThickness();
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).isThicknessable() && listSelected.getFigureAt(i).getThickness()!=thickness)
                                                ok = false;
                              
                                    setThicknessFieldValue(ok ? thickness : genThickness);
                              }
                              else setThicknessFieldValue(genThickness);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).canHaveShadow())
                                          ok = false;
                              
                              if(!ok)
                              {
                                    boolean hasShadow = listSelected.getFigureAt(i-1).hasShadow();
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).canHaveShadow() && listSelected.getFigureAt(i).hasShadow()!=hasShadow)
                                                ok = false;
                                    
                                    shadowCheckBox.setSelected(ok ? hasShadow : genHasShadow);
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).hasShadow())
                                                ok = false;
                                    
                                    if(!ok)
                                    {
                                          Color shadC = listSelected.getFigureAt(i-1).getShadowColor();
                                          
                                          for(i=0, ok=true; i<size && ok; i++)
                                                if(listSelected.getFigureAt(i).hasShadow() && !listSelected.getFigureAt(i).getShadowColor().equals(shadC))
                                                      ok = false;
                                          
                                          genShadowCB.setColor(ok ? shadC : genShadowC);
                                    }
                                    else
                                          genShadowCB.setColor(genShadowC);
                              }
                              else
                                    shadowCheckBox.setSelected(genHasShadow);
                              
                              for(i=0, ok=true; i<size && ok; i++)
                                    if(listSelected.getFigureAt(i).canBeFilled())
                                          ok = false;
                              
                              if(!ok)
                              {
                                    int j = i-1;
                                    boolean isFilled = listSelected.getFigureAt(j).isFilled();
                                    String hatchS = listSelected.getFigureAt(j).getHatchingStyle();
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).canBeFilled() && listSelected.getFigureAt(i).isFilled()!=isFilled)
                                                ok = false;
                                    
                                    filledCheckBox.setSelected(ok ? isFilled : genIsFilled);
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).canBeFilled() && 
                                                (listSelected.getFigureAt(i).hasGradient() || listSelected.getFigureAt(i).isHatched()) &&
                                                !listSelected.getFigureAt(i).getHatchingStyle().equals(hatchS))
                                                ok = false;
                                    
                                    setHatchChoice(ok ? hatchS : genHatchS);
                                    
                                    if(ok)
                                          if(listSelected.getFigureAt(j).hasGradient())
                                          {
                                                Color gradEndC = listSelected.getFigureAt(j).getGradientEndColor();
                                                Color gradStartC = listSelected.getFigureAt(j).getGradientStartColor();
                                                boolean okEnd = true;
                                                
                                                for(i=0, ok=true; i<size; i++)
                                                      if(listSelected.getFigureAt(i).canBeHatched())
                                                      {
                                                            if(!listSelected.getFigureAt(i).getGradientEndColor().equals(gradEndC))
                                                                  okEnd = false;
                                                            if(!listSelected.getFigureAt(i).getGradientStartColor().equals(gradStartC))
                                                                  ok = false;
                                                      }
                                                
                                                genGradientStartCB.setColor(ok ? gradStartC : genGradientStartC);
                                                genGradientEndCB.setColor(okEnd ? gradEndC : genGradientEndC);
                                                genHatchCB.setColor(genHatchC);
                                          }
                                          else
                                          {
                                                Color hatchC = listSelected.getFigureAt(j).getHatchingColor();
                                                
                                                for(i=0, ok=true; i<size; i++)
                                                      if(listSelected.getFigureAt(i).canBeHatched() && 
                                                            !listSelected.getFigureAt(i).getHatchingColor().equals(hatchC))
                                                            ok = false;
                                                
                                                genGradientStartCB.setColor(genGradientStartC);
                                                genGradientEndCB.setColor(genGradientEndC);
                                                genHatchCB.setColor(ok ? hatchC : genHatchC);
                                          }
                                    else
                                    {
                                          genGradientStartCB.setColor(genGradientStartC);
                                          genGradientEndCB.setColor(genGradientEndC);
                                          genHatchCB.setColor(genHatchC);
                                    }
                                    
                                    for(i=0, ok=true; i<size && ok; i++)
                                          if(listSelected.getFigureAt(i).isFilled())
                                                ok = false;
                                    
                                    if(!ok)
                                    {
                                          Color fillC = listSelected.getFigureAt(i-1).getInteriorColor();
                                          
                                          for(ok=true, i=0; i<size && ok; i++)
                                                if(listSelected.getFigureAt(i).isFilled() && !listSelected.getFigureAt(i).getInteriorColor().equals(fillC) &&
                                                      !listSelected.getFigureAt(i).hasGradient())
                                                      ok = false;
                                          
                                          genInteriorCB.setColor(ok ? fillC : genInteriorC);
                                    }
                                    else genInteriorCB.setColor(genInteriorC);
                              }
                              else 
                              {
                                    genInteriorCB.setColor(genInteriorC);
                                    setHatchChoice(genHatchS);
                                    filledCheckBox.setSelected(genIsFilled);
                                    buttonGradientStartC.setColor(genGradientStartC);
                                    buttonGradientEndC.setColor(genGradientEndC);
                                    buttonHatchColor.setColor(genHatchC);
                              }
                        }
                        else// In this case, the general values are used.
                        {
                              setBorderChoice(genBordPosS);
                              setLineChoice(genLineStyleS);
                              setDotChoice(genDotS);
                              dbleBoundCheckBox.setSelected(genHasDbleBord);
                              shadowCheckBox.setSelected(genHasShadow);
                              setHatchChoice(genHatchS);
                              filledCheckBox.setSelected(genIsFilled);
                              setLineArrowLChoice(genLeftArrS);
                              setLineArrowRChoice(genRightArrS);
                              setThicknessFieldValue(genThickness);
                              genDbleBordCB.setColor(genDbleC);
                              genGradientEndCB.setColor(genGradientEndC);
                              genGradientStartCB.setColor(genGradientStartC);
                              genInteriorCB.setColor(genInteriorC);
                              genLineCB.setColor(genLineC);
                              genHatchCB.setColor(genHatchC);
                              genShadowCB.setColor(genShadowC);
                        }
            }catch(Exception ex)
            {
                  ex.printStackTrace();
                  ExceptionFrameDialog.showExceptionDialog(ex);
            }
      }


Generated by  Doxygen 1.6.0   Back to index