package votorola.s.gwt.wic; // Copyright 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import org.vectomatic.dom.svg.*; import votorola.g.web.gwt.svg.*; /** A component of the bridge/stage {@linkplain DIn connector overlay} that visually ties * the other (non-anchor) drafter's link (tLink) at top left of the bridge scene to the * {@linkplain AlterBracket alter bracket}.
  *
  *                             alter   |             |
  *                            bracket  +------+------+
  *                                            |
  *    tLink  +--------------------------------+
*/ final class AlterLine extends Connector { /** Creates an AlterLine. */ AlterLine() { super( "tLink" ); // invisible pending AlterBracket.Visibilizer addClassNameBaseVal( "AlterLine" ); } // ------------------------------------------------------------------------------------ /** Redraws this line to connect with the bracket, or sets it invisible if the bracket * is too close to the link. */ void repaint( final AlterBracket bracket ) { final int linkHeight = link().getOffsetHeight(); final int linkRight = link().getAbsoluteRight(); final int x0 = linkRight + /*margin*/(int)(linkHeight * 0.2f); final OMSVGPathSegMovetoAbs p0 = bracket.p0(); final int midX = (int)( p0.getX() + bracket.length() / 2 ); if( isLongEnough( x0, midX, linkHeight )) setVisible( true ); else { setVisible( false ); return; } // p0 + + - // margin | bracket | | depth // | +--------+---------+ - // |-| | 2 // | // link +--------------------------------+ 1 (midX,y) // 0 final int y = link().getAbsoluteTop() + linkSink(linkHeight); final OMSVGPathSegList sL = getPathSegList(); PathSeg.movetoAbs( sL, 0, x0, y ); PathSeg.lineToAbs( sL, 1, midX, y ); PathSeg.lineToAbs( sL, 2, midX, p0.getY() + bracket.depth() ); } }