You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Appddevvv (JIRA)" <ji...@apache.org> on 2010/07/02 21:46:50 UTC

[jira] Created: (PIVOT-559) use a PivotStyle annotation to help identify style properties on objects

use a PivotStyle annotation to help identify style properties on objects
------------------------------------------------------------------------

                 Key: PIVOT-559
                 URL: https://issues.apache.org/jira/browse/PIVOT-559
             Project: Pivot
          Issue Type: Improvement
          Components: wtk
            Reporter: Appddevvv
            Priority: Minor


Benefits:

a) You can write a scanner to find styles and list them. This helps you avoid having to filter direct bean properties on skins to list styles and identify the canonical style.

b) Helps both clients as well as developers understand the impact of this style on layout and painting.

c) Helps you implement style stacks and preferences so you can pull styles from a skin and save them in preferences without pulling extraneous information from the skin or having to do clever property filtering.

I can include an annotation scanner that returns a list of style annotations from a class if that helps although its quite trivial.

Prototype is below:

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pivot.wtk;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Indicates that a property is a pivot style and provides
 * useful information for drawing optimization and discovery. 
 * 
 * 
 * <p>By convention, the annotation should annotate the setter and not 
 * a field or the getter. Java bean conventions suggests that the 
 * setter takes one parameter. If more than one method with a similar name
 * exists in a class, but has a different setter parameter,
 * choose the setter with the most specific parameter and that
 * does not require a conversion internal to the class to use
 * e.g. choose the setter with the {@code Paint} parameter instead
 * of the setter with the string parameter that has to be parsed
 * to create a {@code Paint} object. Or if the same method name
 * can also take a {@code Color} object but you use a {@code Paint}
 * object in the implementation, still select the {@code Paint}
 * object. It would be up to an external processor to decide
 * if other methods with the same name but different parameters
 * should be used instead.
 *
 */
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PivotStyle {

	/**
	 * When true, indicates this style requires a component invalidation
	 * to force layout because the style affects the layout e.g. the size
	 * of something.
	 */
	boolean affectsLayout() default true;

	/**
	 * When true, indicates this style requires a repaint
	 * if it is set because it affects painting.
	 */
	boolean affectsPainting() default true;

	/**
	 * A description of the style.
	 */
	String description() default "";

	/**
	 * The category of the style such as "Colors" or "Animation".
	 * A category groups similar style properties together for
	 * browsing convenience.
	 */
	String category() default "";

}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-559) use a PivotStyle annotation to help identify style properties on objects

Posted by "Noel Grandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905905#action_12905905 ] 

Noel Grandin commented on PIVOT-559:
------------------------------------

I can't see the point of most of this. 
AffectsPainting and AffectsLayout is mostly irrelevant to most developers.
There would have to be more compelling reasons to justify adding the overhead of something like this to the code.

You don't need to do anything clever to find the styles on a component, you just call Component#getStyles()
For an example of how this is done dynamically, look at
  org.apache.pivot.tutorials.explorer.tools.ComponentStyleInspectorSkin

> use a PivotStyle annotation to help identify style properties on objects
> ------------------------------------------------------------------------
>
>                 Key: PIVOT-559
>                 URL: https://issues.apache.org/jira/browse/PIVOT-559
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>            Reporter: Appddevvv
>            Priority: Minor
>
> Benefits:
> a) You can write a scanner to find styles and list them. This helps you avoid having to filter direct bean properties on skins to list styles and identify the canonical style.
> b) Helps both clients as well as developers understand the impact of this style on layout and painting.
> c) Helps you implement style stacks and preferences so you can pull styles from a skin and save them in preferences without pulling extraneous information from the skin or having to do clever property filtering.
> I can include an annotation scanner that returns a list of style annotations from a class if that helps although its quite trivial.
> Prototype is below:
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to you under the Apache License,
>  * Version 2.0 (the "License"); you may not use this file except in
>  * compliance with the License.  You may obtain a copy of the License at
>  *
>  *     http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package org.apache.pivot.wtk;
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Inherited;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
> /**
>  * Indicates that a property is a pivot style and provides
>  * useful information for drawing optimization and discovery. 
>  * 
>  * 
>  * <p>By convention, the annotation should annotate the setter and not 
>  * a field or the getter. Java bean conventions suggests that the 
>  * setter takes one parameter. If more than one method with a similar name
>  * exists in a class, but has a different setter parameter,
>  * choose the setter with the most specific parameter and that
>  * does not require a conversion internal to the class to use
>  * e.g. choose the setter with the {@code Paint} parameter instead
>  * of the setter with the string parameter that has to be parsed
>  * to create a {@code Paint} object. Or if the same method name
>  * can also take a {@code Color} object but you use a {@code Paint}
>  * object in the implementation, still select the {@code Paint}
>  * object. It would be up to an external processor to decide
>  * if other methods with the same name but different parameters
>  * should be used instead.
>  *
>  */
> @Inherited
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.METHOD)
> public @interface PivotStyle {
> 	/**
> 	 * When true, indicates this style requires a component invalidation
> 	 * to force layout because the style affects the layout e.g. the size
> 	 * of something.
> 	 */
> 	boolean affectsLayout() default true;
> 	/**
> 	 * When true, indicates this style requires a repaint
> 	 * if it is set because it affects painting.
> 	 */
> 	boolean affectsPainting() default true;
> 	/**
> 	 * A description of the style.
> 	 */
> 	String description() default "";
> 	/**
> 	 * The category of the style such as "Colors" or "Animation".
> 	 * A category groups similar style properties together for
> 	 * browsing convenience.
> 	 */
> 	String category() default "";
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.