@@ -27,13 +27,11 @@ public class ClassConstructorPaintComponent extends DataTextIOPaintComponent
2727
2828 private Constructor displayingConstructor ;
2929 private Object instance ;
30- private Object returnVal ;
3130
3231
3332 public ClassConstructorPaintComponent (Constructor displayingContructor ,
34- Object instance , int x , int y ) {
33+ int x , int y ) {
3534 super (displayingContructor .toString (), x , y );
36- this .instance = instance ;
3735 this .displayingConstructor = displayingContructor ;
3836 init ();
3937 }
@@ -46,13 +44,18 @@ private void init() {
4644 addToPoint (i + 1 , new JavaType (paramTypes [i ]));
4745 }
4846
47+ // constructed instance take line length+1
48+ addFromPoint (this , paramTypes .length + 1 ,
49+ new JavaType (this .displayingConstructor .getDeclaringClass ()));
50+
4951 // prepare String
5052 StringBuilder s = new StringBuilder ();
5153 s .append (this .displayingConstructor .toString () + "\n " );
5254 for (int i = 0 ; i < paramTypes .length ; i ++) {
5355 s .append ("arg" + i + " :: " + paramTypes [i ].getName () + "\n " );
5456 }
5557
58+ s .append ("Constructed Instance >>>> " + "\n " );
5659 setDisplayingText (s .toString ());
5760
5861 }
@@ -77,7 +80,7 @@ public void evaluate(DataFromPoint dataFromPoint){
7780 }
7881 }
7982 try {
80- returnVal = displayingConstructor .newInstance (args );
83+ instance = displayingConstructor .newInstance (args );
8184 } catch (InstantiationException | IllegalAccessException
8285 | IllegalArgumentException | InvocationTargetException e ) {
8386 e .printStackTrace ();
@@ -95,7 +98,7 @@ public void evaluate(DataFromPoint dataFromPoint){
9598 public Object provideInformationToDataFromPoint (
9699 DataFromPoint dataFromPoint ) {
97100
98- return returnVal ;
101+ return instance ;
99102 }
100103
101104 /**
@@ -107,26 +110,6 @@ public Object provideInformationToDataFromPoint(
107110 public boolean canProvideInformationToDataFromPoint (
108111 DataFromPoint dataFromPoint ) {
109112
110- return returnVal != null ;
111- }
112-
113- /**
114- * Retrieve the instance of what this component manipulated.
115- * @param dataFromPoint
116- * @return that instance
117- */
118- public Object provideInstanceToDataFromPoint (
119- DataFromPoint dataFromPoint ){
120- return instance ;
121- }
122-
123- /**
124- * Check whether there's an instance to retrieve
125- * @param dataFromPoint
126- * @return true if there is, false if not
127- */
128- public boolean canProvideInstanceToDataFromPoint (
129- DataFromPoint dataFromPoint ){
130113 return instance != null ;
131114 }
132115
0 commit comments