private void safeBeginParagraph() { if (!myParagraphStarted) { myParagraphStarted = true; myBufferIsEmpty = true; beginParagraph(ZLTextParagraph.Kind.TEXT_PARAGRAPH); if (!myParagraphStored) { // final ArrayList models = Model.getBookTextModels(); // myParagraphVector.add(new Pair(((ZLTextPlainModel) // models.get(models.size()-1)/*BookTextModel*/).getParagraphsNumber() - 1, models.size() - // 1)); myParagraphStored = true; } for (Iterator it = myDelayedControls.iterator(); it.hasNext(); ) { Pair pit = (Pair) it.next(); addControl((Byte) pit.myFirst, (Boolean) pit.mySecond); } // if (myForcedEntry != null) { // addControl(myForcedEntry); // } else { addControl(FBTextKind.REGULAR, true); // } for (Iterator it = myDelayedHyperlinks.iterator(); it.hasNext(); ) { addHyperlinkControl(FBTextKind.INTERNAL_HYPERLINK, (String) it.next()); } myDelayedHyperlinks.clear(); } }
public boolean readDocument() { try { myStream = new ZLInputStreamWithOffset(myFile.getInputStream()); PdbHeader header = new PdbHeader(myStream); setMainTextModel(); myFont = FontType.FT_REGULAR; for (int index = 0; index < header.Offsets.length; ++index) { int currentOffset = myStream.offset(); int pit = header.Offsets[index]; if (currentOffset > pit) { break; } // myStream.seek(pit - currentOffset, false); myStream.skip(pit - currentOffset); if (myStream.offset() != pit) { break; } int recordSize = ((index != header.Offsets.length - 1) ? header.Offsets[index + 1] : myFileSize) - pit; readRecord(recordSize); } myStream.close(); } catch (IOException e) { return false; } for (Iterator it = myReferencedParagraphs.iterator(); it.hasNext(); ) { Pair pair = (Pair) it.next(); int first = (Integer) pair.myFirst; int second = (Integer) pair.mySecond; ArrayList /*<Integer>*/ list = (ArrayList) myParagraphMap.get(first); if (list != null) { for (int k = second; k < list.size(); ++k) { if (((Integer) ((Pair) list.get(k)).myFirst) != -1) { // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), // (Integer)list.get(k)); final Pair p = (Pair) list.get(k); // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), (Integer) p.mySecond, // (Integer) p.myFirst); break; } } } } myReferencedParagraphs.clear(); myParagraphMap.clear(); return true; }
private void processTextRecord(int size, ArrayList /*<Integer>*/ pars) { int start = 0; int end = 0; for (Iterator it = pars.iterator(); it.hasNext(); ) { start = end; end = start + (Integer) it.next(); if (end > size) { return; } myParagraphStored = false; processTextParagraph(myCharBuffer, start, end); if (!myParagraphStored) { myParagraphVector.add(new Pair(-1, -1)); } } }
public void draw() { if (_pointLists.size() <= 0) return; pushStyle(); noFill(); PVector vec; PVector firstVec; PVector screenPos = new PVector(); int colorIndex = 0; // draw the hand lists Iterator<Map.Entry> itrList = _pointLists.entrySet().iterator(); while (itrList.hasNext()) { strokeWeight(2); stroke(_colorList[colorIndex % (_colorList.length - 1)]); ArrayList curList = (ArrayList) itrList.next().getValue(); // draw line firstVec = null; Iterator<PVector> itr = curList.iterator(); beginShape(); while (itr.hasNext()) { vec = itr.next(); if (firstVec == null) firstVec = vec; // calc the screen pos context.convertRealWorldToProjective(vec, screenPos); vertex(screenPos.x, screenPos.y); } endShape(); // draw current pos of the hand if (firstVec != null) { strokeWeight(8); context.convertRealWorldToProjective(firstVec, screenPos); point(screenPos.x, screenPos.y); } colorIndex++; } popStyle(); }
private void prepareToDraw() { if (forwardSlot0 != null) { forwardSlot0.setCgview(p); forwardSlot0.setFeatureThickness(featureThickness); } if (forwardSlot1 != null) { forwardSlot1.setCgview(p); forwardSlot1.setFeatureThickness(featureThickness); } if (forwardSlot2 != null) { forwardSlot2.setCgview(p); forwardSlot2.setFeatureThickness(featureThickness); } if (forwardSlot3 != null) { forwardSlot3.setCgview(p); forwardSlot3.setFeatureThickness(featureThickness); } if (forwardSlot4 != null) { forwardSlot4.setCgview(p); forwardSlot4.setFeatureThickness(featureThickness); } if (forwardSlot5 != null) { forwardSlot5.setCgview(p); forwardSlot5.setFeatureThickness(featureThickness); } if (forwardSlot6 != null) { forwardSlot6.setCgview(p); forwardSlot6.setFeatureThickness(featureThickness); } if (forwardSlot7 != null) { forwardSlot7.setCgview(p); forwardSlot7.setFeatureThickness(featureThickness); } if (reverseSlot0 != null) { reverseSlot0.setCgview(p); reverseSlot0.setFeatureThickness(featureThickness); } if (reverseSlot1 != null) { reverseSlot1.setCgview(p); reverseSlot1.setFeatureThickness(featureThickness); } if (reverseSlot2 != null) { reverseSlot2.setCgview(p); reverseSlot2.setFeatureThickness(featureThickness); } if (reverseSlot3 != null) { reverseSlot3.setCgview(p); reverseSlot3.setFeatureThickness(featureThickness); } if (reverseSlot4 != null) { reverseSlot4.setCgview(p); reverseSlot4.setFeatureThickness(featureThickness); } if (reverseSlot5 != null) { reverseSlot5.setCgview(p); reverseSlot5.setFeatureThickness(featureThickness); } if (reverseSlot6 != null) { reverseSlot6.setCgview(p); reverseSlot6.setFeatureThickness(featureThickness); } if (reverseSlot7 != null) { reverseSlot7.setCgview(p); reverseSlot7.setFeatureThickness(featureThickness); } if (restrictionSlot != null) { restrictionSlot.setCgview(p); restrictionSlot.setFeatureThickness(featureThickness); } // send settings to p if (showTitle) { p.setTitle(title); } p.setWidth(imageWidth); p.setHeight(imageHeight); p.setLabelsToKeep(MAXLABELS); p.setDrawTickMarks(drawTickMarks); p.setTitleFont(titleFont); p.setLabelFont(labelFont); p.setFeatureThickness(featureThickness); p.setBackboneThickness(backboneThickness); p.setFeatureSlotSpacing(featureSpacing); p.setLegendFont(legendFont); p.setTickLength(tickLength); p.setLabelLineLength(labelLineLength); p.setLabelPlacementQuality(labelPlacementQuality); p.setUseColoredLabelBackgrounds(useColoredLabelBackground); p.setShowBorder(showBorder); p.setShowShading(showShading); p.setShadingProportion(shadingProportion); p.setUseInnerLabels(useInnerLabels); p.setMoveInnerLabelsToOuter(moveInnerLabelsToOuter); p.setWarningFont(rulerFont); p.setRulerFont(rulerFont); // if not drawing labels, don't show message. if (!(showLabels)) { p.setShowWarning(false); } // set backboneRadius based on smallest image dimension int smallestDimension = Math.min(imageWidth, imageHeight); if (smallestDimension <= 750) { p.setBackboneRadius(0.50d * (double) smallestDimension / 2.0d); } else { p.setBackboneRadius(0.50d * 750.0d / 2.0d); } // check coloredLabels if (!(useColoredLabels)) { if (colorScheme == REGULAR) { p.setGlobalLabelColor((Color) MAP_ITEM_COLORS.get("titleFont")); } else if (colorScheme == INVERSE) { p.setGlobalLabelColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont")); } } // set map item colors if (colorScheme == REGULAR) { p.setLongTickColor((Color) MAP_ITEM_COLORS.get("tick")); p.setShortTickColor((Color) MAP_ITEM_COLORS.get("partialTick")); p.setZeroTickColor((Color) MAP_ITEM_COLORS.get("zeroLine")); p.setRulerFontColor((Color) MAP_ITEM_COLORS.get("rulerFont")); p.setBackboneColor((Color) MAP_ITEM_COLORS.get("backbone")); p.setTitleFontColor((Color) MAP_ITEM_COLORS.get("titleFont")); p.setWarningFontColor((Color) MAP_ITEM_COLORS.get("titleFont")); p.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background")); } else if (colorScheme == INVERSE) { p.setLongTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("tick")); p.setShortTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("partialTick")); p.setZeroTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("zeroLine")); p.setRulerFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("rulerFont")); p.setBackboneColor((Color) MAP_ITEM_COLORS_INVERSE.get("backbone")); p.setTitleFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont")); p.setWarningFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont")); p.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background")); } // build legend if ((showLegend) && (DRAW_LEGEND_ITEMS.size() > 0)) { // create legend legend = new Legend(p); legend.setAllowLabelClash(allowLabelClashLegend); legend.setBackgroundOpacity(0.5f); legend.setFont(legendFont); legend.setPosition(legendPosition); if (colorScheme == REGULAR) { legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background")); legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont")); } else if (colorScheme == INVERSE) { legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background")); legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont")); } LegendItem legendItem; Enumeration legendEntries = DRAW_LEGEND_ITEMS.keys(); ArrayList list = new ArrayList(); while (legendEntries.hasMoreElements()) { list.add(legendEntries.nextElement()); } Collections.sort(list); Iterator i = list.iterator(); while (i.hasNext()) { String key = (String) i.next(); legendItem = new LegendItem(legend); legendItem.setDrawSwatch(SWATCH_SHOW); legendItem.setLabel((String) LEGEND_ITEM_NAMES.get(key)); if (colorScheme == REGULAR) { legendItem.setSwatchColor((Color) FEATURE_COLORS.get(key)); } else if (colorScheme == INVERSE) { legendItem.setSwatchColor((Color) FEATURE_COLORS_INVERSE.get(key)); } } } // set message if (showMessage) { legend = new Legend(p); legend.setAllowLabelClash(false); legend.setBackgroundOpacity(0.5f); legend.setFont(messageFont); legend.setPosition(LEGEND_LOWER_RIGHT); LegendItem legendItem; if (colorScheme == REGULAR) { legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background")); legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont")); legendItem = new LegendItem(legend); legendItem.setLabel(message); legendItem.setDrawSwatch(SWATCH_NO_SHOW); } else if (colorScheme == INVERSE) { legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background")); legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont")); legendItem = new LegendItem(legend); legendItem.setLabel(message); legendItem.setDrawSwatch(SWATCH_NO_SHOW); } } }