1 19 20 25 26 package org.netbeans.modules.css.visual.model; 27 28 import java.util.StringTokenizer ; 29 30 35 public class ClipData extends PropertyData{ 36 37 PropertyWithUnitData topValue = new PropertyWithUnitData(); 38 PropertyWithUnitData bottomValue = new PropertyWithUnitData(); 39 PropertyWithUnitData leftValue = new PropertyWithUnitData(); 40 PropertyWithUnitData rightValue = new PropertyWithUnitData(); 41 42 public void setClip(String clip){ 43 topValue.clear(); 44 bottomValue.clear(); 45 leftValue.clear(); 46 rightValue.clear(); 47 if(clip != null){ 48 int start = clip.indexOf("("); 49 int stop = clip.indexOf(")"); 50 if((start != -1) && (stop != -1)){ 51 String clipString = clip.substring(start + 1, stop); 52 StringTokenizer st = new StringTokenizer (clipString,","); 53 54 if(st.hasMoreTokens()){ 55 setTop(st.nextToken()); 56 } 57 if(st.hasMoreTokens()){ 58 setRight(st.nextToken()); 59 } 60 if(st.hasMoreTokens()){ 61 setBottom(st.nextToken()); 62 } 63 if(st.hasMoreTokens()){ 64 setLeft(st.nextToken()); 65 } 66 } 67 } 68 } 69 70 public void setTop(String clipTopStr){ 71 topValue.setData(clipTopStr); 72 } 73 74 public void setBottom(String clipBottomStr){ 75 bottomValue.setData(clipBottomStr); 76 } 77 78 public void setLeft(String clipLeftStr){ 79 leftValue.setData(clipLeftStr); 80 } 81 82 public void setRight(String clipRightStr){ 83 rightValue.setData(clipRightStr); 84 } 85 86 public void setTopValue(String top){ 87 topValue.setValue(top); 88 } 89 90 public void setTopUnit(String topUnit){ 91 topValue.setUnit(topUnit); 92 } 93 94 public void setBottomValue(String bottom){ 95 bottomValue.setValue(bottom); 96 } 97 98 public void setBottomUnit(String bottomUnit){ 99 bottomValue.setUnit(bottomUnit); 100 } 101 102 public void setLeftValue(String left){ 103 leftValue.setValue(left); 104 } 105 106 public void setLeftUnit(String leftUnit){ 107 leftValue.setUnit(leftUnit); 108 } 109 110 public void setRightValue(String right){ 111 rightValue.setValue(right); 112 } 113 114 public void setRightUnit(String rightUnit){ 115 rightValue.setUnit(rightUnit); 116 } 117 118 public String getTopValue(){ 119 return topValue.getValue(); 120 } 121 122 public String getTopUnit(){ 123 return topValue.getUnit(); 124 } 125 126 public String getBottomValue(){ 127 return bottomValue.getValue(); 128 } 129 130 public String getBottomUnit(){ 131 return bottomValue.getUnit(); 132 } 133 134 public String getLeftValue(){ 135 return leftValue.getValue(); 136 } 137 138 public String getLeftUnit(){ 139 return leftValue.getUnit(); 140 } 141 142 public String getRightValue(){ 143 return rightValue.getValue(); 144 } 145 146 public String getRightUnit(){ 147 return rightValue.getUnit(); 148 } 149 150 public boolean isTopValueInteger(){ 151 return topValue.isValueInteger(); 152 } 153 154 public boolean isBottomValueInteger(){ 155 return bottomValue.isValueInteger(); 156 } 157 158 public boolean isLeftValueInteger(){ 159 return leftValue.isValueInteger(); 160 } 161 162 public boolean isRightValueInteger(){ 163 return rightValue.isValueInteger(); 164 } 165 166 public String toString(){ 167 if(!topValue.hasValue() && !rightValue.hasValue() && !bottomValue.hasValue() && !leftValue.hasValue()){ 168 return ""; 169 } 170 String clipString = ""; 171 if (topValue.hasValue()){ 172 clipString += " " + topValue.toString(); 173 }else{ 174 clipString += " 0px"; } 176 if (rightValue.hasValue()){ 177 clipString += ", " + rightValue.toString(); 178 }else{ 179 clipString += ", 0px"; } 181 if (bottomValue.hasValue()){ 182 clipString += ", " + bottomValue.toString(); 183 }else{ 184 clipString += ", 0px"; } 186 187 if (leftValue.hasValue()){ 188 clipString += ", " + leftValue.toString(); 189 }else{ 190 clipString += ", 0px"; } 192 clipString = "rect(" + clipString.trim() + ")"; return clipString.trim(); 194 } 195 196 197 } 198 | Popular Tags |