/** * Marks styles as either referencing or referenced. * * @param style the parent style * @param referencedStylesByName a map in which referenced styles are marked */ private void markReferences( Style style, HashMap<String, Style> referencedStylesByName, CssAttributesManager attributesManager) { String[] references = style.getReferencedStyleNames(attributesManager); for (int i = 0; i < references.length; i++) { String referencedStyleName = references[i].toLowerCase(); if (referencedStyleName.charAt(0) == '.') { referencedStyleName = referencedStyleName.substring(1); } Style referencedStyle = getStyle(referencedStyleName); if (referencedStyle != null) { // if (style.getSelector().equals(referencedStyleName)) { // System.out.println("style references itself: style=[" + style.getSelector() + "] // references " + referencedStyleName ); // continue; // } style.addReferencedStyle(referencedStyle); referencedStyle.setIsReferenced(true); Style reference = (Style) referencedStylesByName.get(referencedStyleName); if (reference == null) { // this style has not been referenced before referencedStylesByName.put(referencedStyleName, referencedStyle); markReferences(referencedStyle, referencedStylesByName, attributesManager); } } } }
/** * Resolve original style for Cell. * * @param fods * @param cell * @return Style display name. */ public static String getTopParentStyleName(Workbook fods, Cell cell) { String result = cell.getStyle(); if (result == null) { return null; } // Look for automatic style for (AutomaticStyle s : fods.getAutomaticStyles()) { if (s.getName().equals(result)) { result = s.getParentName(); break; } } // Next style should be a standard style for (Style s : fods.getStyles()) { if (s.getName().equals(result)) { result = s.getDisplayName(); break; } } return result; }
/** * Resolve original style for Sheet. * * @param fods * @param table * @return Style display name. */ public static String getTopParentStyleName(Workbook fods, Sheet table) { String result = table.getStyleName(); if (result == null) { return null; } // Look for automatic style for (AutomaticStyle s : fods.getAutomaticStyles()) { if (s.getName().equals(result)) { result = s.getMasterPageName(); break; } } // Next style should be a master style for (Style s : fods.getMasterStyles()) { if (s.getName().equals(result)) { result = s.getDisplayName(); break; } } return result; }
/** * Outputs the named style. <code>outputStyle</code> indicates whether or not a style has been * output yet. This will return true if a style is written. */ boolean writeStyle(String name, Style style, boolean outputStyle) throws IOException { boolean didOutputStyle = false; Enumeration attributes = style.getAttributeNames(); if (attributes != null) { while (attributes.hasMoreElements()) { Object attribute = attributes.nextElement(); if (attribute instanceof CSS.Attribute) { String value = style.getAttribute(attribute).toString(); if (value != null) { if (!outputStyle) { writeStyleStartTag(); outputStyle = true; } if (!didOutputStyle) { didOutputStyle = true; indent(); write(name); write(" {"); } else { write(";"); } write(' '); write(attribute.toString()); write(": "); write(value); } } } } if (didOutputStyle) { write(" }"); writeLineSeparator(); } return didOutputStyle; }
/** * Sets the parents of the styles. This method is automatically called when the sourcecode will be * retrieved. * * @throws BuildException when invalid inheritances are found. * @see #isInherited() * @see #getSourceCode() */ public void oldInherit() { // create default-style when not explicitly defined: if (this.stylesByName.get("default") == null) { addCssBlock(DEFAULT_STYLE); } Style[] allStyles = getAllStyles(); for (int i = 0; i < allStyles.length; i++) { Style style = allStyles[i]; // System.out.println("inheriting style [" + style.getSelector() + "]."); checkInheritanceHierarchy(style); String parentName = style.getParentName(); if (parentName != null) { Style parent = getStyle(parentName); if (parent == null) { throw new BuildException( "Invalid CSS code: the style [" + style.getSelector() + "] extends the non-existing style [" + parentName + "]."); } style.setParent(parent); } } this.isInitialised = true; }
public void setBassInstrument(int instrument) { bassInstrument = instrument; Style style = chordProg.getStyle(); if (style != null) { style.setBassInstrument(instrument); } }
private void inheritDo(Style style, HashSet<String> set) { String parentName = style.getParentName(); String currentName = style.getSelector(); if (parentName == null) { // System.out.println("style [" + currentName + "] no parent."); return; // No parent. } else if (set.contains(currentName)) { // System.out.println("style [" + currentName + "] has been set."); return; // Has been set } else { checkInheritanceHierarchy(style); Style parent = getStyle(parentName); // System.out.println("inheriting style [" + currentName + "] from style [" + parentName + // "]."); if (parent == null) { throw new BuildException( "Invalid CSS code: the style [" + currentName + "] extends the non-existing style [" + parentName + "]."); } inheritDo(parent, set); style.setParent(parent); set.add(currentName); } }
public void setStyle(Style style) { if (!style.equals(getCustomStyle())) { this.changeLayout(style.getLayout()); this.rotationView.setRotation( style.getRotationX(), style.getRotationY(), style.getRotationZ()); } }
/** * Checks whether the inheritance hierarchy is correct. An incorrect hierarchy is for example a * loop definition, in which a parent-style extends a child-style: * * <pre> * myStyle extends parent { * font-face: monospace; * } * parent extends grandparent { * font-size: large; * font-face: system; * } * grandparent extends myStyle { * background-color: white; * } * </pre> * * @param style the style whose inheritance hierarchy should be checked. * @throws BuildException when a circle definition is found. */ private void checkInheritanceHierarchy(Style style) { HashMap<String, Boolean> parentNames = new HashMap<String, Boolean>(5); // System.out.println("checking inheritance of style " + style.getSelector()); String originalSelector = style.getSelector(); String parentName = style.getParentName(); while (parentName != null) { // System.out.println( style.getSelector() + " extends " + parentName ); String currentSelector = style.getSelector(); parentName = parentName.toLowerCase(); if (parentNames.get(parentName) == null) { // okay, this ancestor is not known yet. parentNames.put(parentName, Boolean.TRUE); } else { throw new BuildException( "Invalid CSS code: Loop in inheritance found: The style [" + originalSelector + "] extends the child-style [" + parentName + "]. Please check your extends operator."); } style = getStyle(parentName); if (style == null) { throw new BuildException( "Invalid CSS code: The style [" + currentSelector + "] extends the non-existing style [" + parentName + "]. Please define the style [" + parentName + "] or remove the extends operator."); } parentName = style.getParentName(); } }
public void setLastColumn(boolean b) { if (b) { this.addStyleName(style.last()); } else { this.removeStyleName(style.last()); } }
// #ifdef polish.usePolishGui public void setStyle(Style style) { super.setStyle(style); this.font = style.getFont(); this.linePadding = style.getPaddingHorizontal(10); this.fontColor = style.getFontColor(); requestInit(); }
/** * Retrieves for a preprocessing-symbol for each defined CSS-attribute. When the attribute * ticker-step is defined, the preprocessing-symbol "polish.css.ticker-step" will be defined. * * @param device the current device * @return a map containing all defined symbols as keys with each having a Boolean.TRUE as value. */ public HashMap<String, Boolean> getCssPreprocessingSymbols(Device device) { CssAttributesManager cssAttributesManager = CssAttributesManager.getInstance(); if (this.cssPreprocessingSymbols == null) { HashMap<String, Boolean> symbols = new HashMap<String, Boolean>(); HashMap<String, Boolean> attributesByName = new HashMap<String, Boolean>(); if (this.mediaQueries != null) { symbols.put("polish.css.mediaquery", Boolean.TRUE); } Style[] myStyles = getAllStyles(); for (int i = 0; i < myStyles.length; i++) { Style style = myStyles[i]; symbols.put("polish.css.style." + style.getStyleName(), Boolean.TRUE); String[] attributes = style.getDefinedAttributes(device); for (int j = 0; j < attributes.length; j++) { String attribute = attributes[j]; // System.out.println("adding symbol polish.css." + attribute + " of style " + // style.getSelector() ); symbols.put("polish.css." + attribute, Boolean.TRUE); attributesByName.put(attribute, Boolean.TRUE); } CssDeclarationBlock[] blocks = style.getDeclarationBlocksEndingWith("-animation"); if (blocks.length > 0) { symbols.put("polish.css.animations", Boolean.TRUE); } for (int j = 0; j < blocks.length; j++) { CssDeclarationBlock block = blocks[j]; String cssAttributeName = block .getBlockName() .substring(0, block.getBlockName().length() - "-animation".length()); CssAttribute cssAttribute = cssAttributesManager.getAttribute(cssAttributeName); if (cssAttribute == null) { int hyphenPos = cssAttributeName.indexOf('-'); if (hyphenPos != -1) { String groupName = cssAttributeName.substring(0, hyphenPos); String type = style.getValue(groupName, "type"); if (type == null) { type = "simple"; } String alternativeCssAttributeName = groupName + "-" + type + cssAttributeName.substring(hyphenPos); cssAttribute = cssAttributesManager.getAttribute(alternativeCssAttributeName); if (cssAttribute != null) { cssAttributeName = alternativeCssAttributeName; block.setBlockName(cssAttributeName + "-animation"); } } } if (cssAttribute != null) { symbols.put("polish.css." + cssAttributeName, Boolean.TRUE); } } } this.cssPreprocessingSymbols = symbols; this.cssAttributes = attributesByName; } return this.cssPreprocessingSymbols; }
public void setChordInstrument(int instrument) { // System.out.println("score setChordInstrument to " + instrument); chordProg.setChordInstrument(instrument); Style style = chordProg.getStyle(); if (style != null) { style.setChordInstrument(instrument, "Score"); } }
/** * sets a list of style that can be used form rendering the layer. * * @param styles */ public void setStyles(Style[] styles) { if (styles == null) { this.styles.clear(); } else { for (Style style : styles) { this.styles.put(style.getName(), style); } } }
private void setSyntaxTheme(int tokenType, String id) { Style style = getSyntaxScheme().getStyle(tokenType); Map<String, Object> styledFont = processing.app.Theme.getStyledFont(id, style.font); style.foreground = (Color) styledFont.get("color"); style.font = (Font) styledFont.get("font"); getSyntaxScheme().setStyle(tokenType, style); }
static Style fromInt(int enumValue) { for (Style style : values()) { if (style.getValue() == enumValue) { return style; } } return null; }
@Test public void testEquals() { Style instance = createStyle(data.s1); Style obj = createStyle(data.s2); boolean expected = data.expected; boolean actual = instance.equals(obj); assertTrue(data.toString(), expected == actual); }
/** Calls makeSwing on each individual Part. */ public void makeSwing() { ListIterator<MelodyPart> i = partList.listIterator(); while (i.hasNext()) { MelodyPart m = i.next(); Style style = chordProg.getStyle(); if (style != null) { m.setSwing(style.getSwing()); } m.makeSwing(chordProg.getSectionInfo()); } }
private void makeEditable(boolean editable) { if (editable) { editorPanel.setStylePrimaryName(style.editorPanelVisible()); viewPanel.setStylePrimaryName(style.viewPanelHidden()); clickToEdit.setText("Done"); } else { editorPanel.setStylePrimaryName(style.editorPanelHidden()); viewPanel.setStylePrimaryName(style.viewPanelVisible()); clickToEdit.setText("Edit"); } }
/** constructs a Placemark from a Polyline overlay, as a KML LineString */ public KmlPlacemark(Polyline polyline, KmlDocument kmlDoc) { this(); mName = "LineString - " + polyline.getNumberOfPoints() + " points"; mGeometry = new KmlLineString(); mGeometry.mCoordinates = (ArrayList<GeoPoint>) polyline.getPoints(); mVisibility = polyline.isEnabled(); // Style: Style style = new Style(); style.mLineStyle = new LineStyle(polyline.getColor(), polyline.getWidth()); mStyle = kmlDoc.addStyle(style); }
/** * Retrieves all dynamic styles. * * @return all dynamic styles. */ public Style[] getDynamicStyles() { ArrayList<Style> dynamicStyles = new ArrayList<Style>(); Style[] allStyles = getAllStyles(); for (int i = 0; i < allStyles.length; i++) { Style style = allStyles[i]; if (style.isDynamic()) { dynamicStyles.add(style); } } return (Style[]) dynamicStyles.toArray(new Style[dynamicStyles.size()]); }
private void addSumBottom() { for (int i = 0; i < book.getNumberOfSheets(); i++) { Sheet sheet = book.getSheetAt(i); Row row = sheet.createRow(sheet.getLastRowNum() + 1); row.setHeight((short) (ROW_HEIGHT + 100)); for (int j = 0; j < 1000000; j++) { if (StringUtils.isBlank(CellUtils.getStringValue(sheet.getRow(0).getCell(j))) && StringUtils.isBlank(CellUtils.getStringValue(sheet.getRow(2).getCell(j)))) { break; } Cell cell = row.createCell(j); cell.setCellStyle(Style.get(book).SUM); if (j == 0) { cell.setCellValue("合计"); } else { cell.setCellValue(0); } if (j >= 7) { cell.setCellType(Cell.CELL_TYPE_FORMULA); cell.setCellFormula( String.format( "SUM(%s%s:%s%s)", CellUtils.convertToABC(j + 1), 5, CellUtils.convertToABC(j + 1), sheet.getLastRowNum())); } } sheet.addMergedRegion( new CellRangeAddress(sheet.getLastRowNum(), sheet.getLastRowNum(), 0, 6)); } for (int i = 0; i < book.getNumberOfSheets(); i++) { Sheet sheet = book.getSheetAt(i); for (int j = 4; j <= sheet.getLastRowNum(); j++) { Row row = sheet.getRow(j); for (int k = 0; k <= row.getLastCellNum(); k++) { Cell cell = row.getCell(k); if (cell == null) { continue; } if ("数量".equals(CellUtils.getStringValue(sheet.getRow(2).getCell(k)))) { cell.setCellStyle(Style.get(book).SUM); } } } } }
/** * Update the color in the default style of the document. * * @param color the new color to use or null to remove the color attribute from the document's * style */ private void updateForeground(Color color) { StyledDocument doc = (StyledDocument) getComponent().getDocument(); Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); if (style == null) { return; } if (color == null) { style.removeAttribute(StyleConstants.Foreground); } else { StyleConstants.setForeground(style, color); } }
protected void copy(EditorConfiguration src, EditorConfiguration dst) { dst.title = src.title; dst.mimeType = src.mimeType; Enumeration styleNames = src.styleContext.getStyleNames(); if (src.styleContext == dst.styleContext) dst.styleContext = new StyleContext(); while (styleNames.hasMoreElements()) { String sname = (String) styleNames.nextElement(); Style style = src.styleContext.getStyle(sname); Style newStyle = dst.styleContext.addStyle(sname, null); newStyle.addAttributes(style.copyAttributes()); } styleNames = dst.styleContext.getStyleNames(); while (styleNames.hasMoreElements()) { String sname = (String) styleNames.nextElement(); Style style = src.styleContext.getStyle(sname); AttributeSet resolveParent = style.getResolveParent(); Style parent = (Style) resolveParent; if (parent != null) { dst.styleContext .getStyle(sname) .setResolveParent(dst.styleContext.getStyle(parent.getName())); } } }
/** constructs a Placemark from a Polygon overlay, as a KML Polygon */ public KmlPlacemark(Polygon polygon, KmlDocument kmlDoc) { this(); mName = polygon.getTitle(); mDescription = polygon.getSnippet(); mGeometry = new KmlPolygon(); mGeometry.mCoordinates = (ArrayList<GeoPoint>) polygon.getPoints(); ((KmlPolygon) mGeometry).mHoles = (ArrayList<ArrayList<GeoPoint>>) polygon.getHoles(); mVisibility = polygon.isEnabled(); // Style: Style style = new Style(); style.mPolyStyle = new ColorStyle(polygon.getFillColor()); style.mLineStyle = new LineStyle(polygon.getStrokeColor(), polygon.getStrokeWidth()); mStyle = kmlDoc.addStyle(style); }
/** * returns the <tt>UserStyle</tt> (SLD) representation of the style identified by the submitted * name. * * @param name of the requested style * @return SLD - UserStyle */ public UserStyle getStyle(String name) { Style style = styles.get(name); UserStyle us = null; if (style == null) { if (parent != null) { us = parent.getStyle(name); } } else { us = style.getStyleContent(); } return us; }
public static Style getStyle(String str) { try { return Style.valueOf(str); } catch (Exception ex) { throw new SolrException(ErrorCode.BAD_REQUEST, "Unknown Explain Style: " + str); } }
NodePresenter(VGraphExplorer parent, NodeProxy model) { this.parent = parent; this.model = model; graph = parent.getGraph(); view.setTitle(model.getId()); Style style = view.getElement().getStyle(); style.setLeft(model.getX(), Unit.PX); style.setTop(model.getY(), Unit.PX); view.addDomHandler(this, MouseDownEvent.getType()); view.addDomHandler(this, MouseMoveEvent.getType()); view.addDomHandler(this, MouseUpEvent.getType()); parent.add(view); }
public void draw(Canvas canvas, CanvasPaints paints) { // Assume canvas has identity matrix on its matrix stack. canvas.setMatrix(this.getCascade()); style.setPaints(paints); canvas.drawPath(path.path, paints.stroke()); paints.reset(); }
private void initSeekBar(AttributeSet attrs, int defStyleAttr) { if (isInEditMode()) return; colorControl = Carbon.getThemeColor(getContext(), R.attr.colorControlNormal); thumbRadius = thumbRadius2 = THUMB_RADIUS = Carbon.getDip(getContext()) * 8; THUMB_RADIUS_DRAGGED = Carbon.getDip(getContext()) * 10; STROKE_WIDTH = Carbon.getDip(getContext()) * 2; if (attrs != null) { Carbon.initAnimations(this, attrs, defStyleAttr); Carbon.initTint(this, attrs, defStyleAttr); Carbon.initRippleDrawable(this, attrs, defStyleAttr); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SeekBar, defStyleAttr, 0); setStyle(Style.values()[a.getInt(R.styleable.SeekBar_carbon_barStyle, 0)]); setMin(a.getFloat(R.styleable.SeekBar_carbon_min, 0)); setMax(a.getFloat(R.styleable.SeekBar_carbon_max, 0)); setStepSize(a.getFloat(R.styleable.SeekBar_carbon_stepSize, 0)); setValue(a.getFloat(R.styleable.SeekBar_carbon_value, 0)); setValue2(a.getFloat(R.styleable.SeekBar_carbon_value2, 0)); a.recycle(); } setFocusableInTouchMode(false); // TODO: from theme }