Segment.java revision 3db9393ba06bbf70fa7b4a6db1ef60396979a1d4
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.ide.common.api; 18 19import com.google.common.annotations.Beta; 20 21/** 22 * A segment is a straight horizontal or vertical line between two points, typically an 23 * edge of a node but also possibly some internal segment like a baseline or a center 24 * line, and it can be offset by a margin from the node's visible bounds. 25 * <p> 26 * <b>NOTE: This is not a public or final API; if you rely on this be prepared 27 * to adjust your code for the next tools release.</b> 28 */ 29@Beta 30public class Segment { 31 /** For horizontal lines, the y coordinate; for vertical lines the x */ 32 public final int at; 33 34 /** The starting coordinate along the line */ 35 public final int from; 36 37 /** The ending coordinate along the line */ 38 public final int to; 39 40 /** Whether the edge is a top edge, a baseline edge, a left edge, etc */ 41 public final SegmentType edgeType; 42 43 /** 44 * Whether the edge is offset from the node by a margin or not, or whether it has no 45 * margin 46 */ 47 public final MarginType marginType; 48 49 /** The node that contains this edge */ 50 public final INode node; 51 52 /** 53 * The id of the node. May be null (in which case id should be generated when 54 * move/resize is completed 55 */ 56 public final String id; 57 58 public Segment(int at, int from, int to, INode node, String id, SegmentType edgeType, 59 MarginType marginType) { 60 this.at = at; 61 this.from = from; 62 this.to = to; 63 this.node = node; 64 this.id = id; 65 this.edgeType = edgeType; 66 this.marginType = marginType; 67 } 68 69 @Override 70 public String toString() { 71 String nodeStr = node == null ? "null" : node.getFqcn().substring( 72 node.getFqcn().lastIndexOf(('.')) + 1); 73 return "Segment [edgeType=" + edgeType + ", node=" + nodeStr + ", at=" + at + ", id=" + id 74 + ", from=" + from + ", to=" + to + ", marginType=" + marginType + "]"; 75 } 76} 77