@@ -641,7 +641,10 @@ def boxes_to_mathml(self, leaves=None, **options):
641641
642642 elements ._apply_boxscaling (boxscale )
643643
644- json_repr = elements .to_json ()
644+ # FIXME: json is the only thing we can convert MathML into.
645+ # Handle other graphics formats.
646+ format_fn = lookup_method (elements , "json" )
647+ json_repr = format_fn (elements , ** options )
645648
646649 xmin , xmax , ymin , ymax , zmin , zmax , boxscale = calc_dimensions ()
647650
@@ -788,12 +791,6 @@ def _apply_boxscaling(self, boxscale):
788791 for element in self .elements :
789792 element ._apply_boxscaling (boxscale )
790793
791- def to_json (self ):
792- result = []
793- for element in self .elements :
794- result .extend (element .to_json ())
795- return result
796-
797794 def get_style_class (self ):
798795 return Style3D
799796
@@ -805,25 +802,6 @@ def init(self, *args, **kwargs):
805802 def process_option (self , name , value ):
806803 super (Point3DBox , self ).process_option (name , value )
807804
808- def to_json (self ):
809- # TODO: account for point size
810- data = []
811-
812- # Tempoary bug fix: default Point color should be black not white
813- face_color = self .face_color
814- if list (face_color .to_rgba ()[:3 ]) == [1 , 1 , 1 ]:
815- face_color = RGBColor (components = (0 , 0 , 0 , face_color .to_rgba ()[3 ]))
816-
817- for line in self .lines :
818- data .append (
819- {
820- "type" : "point" ,
821- "coords" : [coords .pos () for coords in line ],
822- "color" : face_color .to_rgba (),
823- }
824- )
825- return data
826-
827805 def extent (self ):
828806 result = []
829807 for line in self .lines :
@@ -845,19 +823,6 @@ def init(self, *args, **kwargs):
845823 def process_option (self , name , value ):
846824 super (Line3DBox , self ).process_option (name , value )
847825
848- def to_json (self ):
849- # TODO: account for line widths and style
850- data = []
851- for line in self .lines :
852- data .append (
853- {
854- "type" : "line" ,
855- "coords" : [coords .pos () for coords in line ],
856- "color" : self .edge_color .to_rgba (),
857- }
858- )
859- return data
860-
861826 def extent (self ):
862827 result = []
863828 for line in self .lines :
@@ -884,27 +849,6 @@ def process_option(self, name, value):
884849 else :
885850 super (Polygon3DBox , self ).process_option (name , value )
886851
887- def to_json (self ):
888- # TODO: account for line widths and style
889- if self .vertex_colors is None :
890- face_color = self .face_color
891- else :
892- face_color = None
893-
894- if face_color is not None :
895- face_color = face_color .to_js ()
896-
897- data = []
898- for line in self .lines :
899- data .append (
900- {
901- "type" : "polygon" ,
902- "coords" : [coords .pos () for coords in line ],
903- "faceColor" : face_color ,
904- }
905- )
906- return data
907-
908852 def extent (self ):
909853 result = []
910854 for line in self .lines :
@@ -1098,19 +1042,6 @@ def init(self, graphics, style, item):
10981042 self .points = [Coords3D (graphics , pos = point ) for point in points ]
10991043 self .radius = item .leaves [1 ].to_python ()
11001044
1101- def to_json (self ):
1102- face_color = self .face_color
1103- if face_color is not None :
1104- face_color = face_color .to_js ()
1105- return [
1106- {
1107- "type" : "sphere" ,
1108- "coords" : [coords .pos () for coords in self .points ],
1109- "radius" : self .radius ,
1110- "faceColor" : face_color ,
1111- }
1112- ]
1113-
11141045 def extent (self ):
11151046 result = []
11161047 result .extend (
0 commit comments