001package conexp.fx.gui.graph.option;
002
003/*
004 * #%L
005 * Concept Explorer FX
006 * %%
007 * Copyright (C) 2010 - 2023 Francesco Kriegel
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as
011 * published by the Free Software Foundation, either version 3 of the
012 * License, or (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU General Public
020 * License along with this program.  If not, see
021 * <http://www.gnu.org/licenses/gpl-3.0.html>.
022 * #L%
023 */
024
025import conexp.fx.core.collections.Pair;
026import conexp.fx.core.context.Concept;
027import conexp.fx.core.context.ConceptLattice;
028import conexp.fx.core.context.Context;
029
030public enum EdgeStroke
031{
032  NONE("None")
033  {
034    public <G, M> double get(
035        final Context<G, M> context,
036        final ConceptLattice<G, M> lattice,
037        final Pair<Concept<G, M>, Concept<G, M>> concepts)
038    {
039      return 0d;
040    }
041  },
042  TINY("Tiny")
043  {
044    public <G, M> double get(
045        final Context<G, M> context,
046        final ConceptLattice<G, M> lattice,
047        final Pair<Concept<G, M>, Concept<G, M>> concepts)
048    {
049      return 0.5d;
050    }
051  },
052  SMALL("Small")
053  {
054    public <G, M> double get(
055        final Context<G, M> context,
056        final ConceptLattice<G, M> lattice,
057        final Pair<Concept<G, M>, Concept<G, M>> concepts)
058    {
059      return 1d;
060    }
061  },
062  NORMAL("Normal")
063  {
064    public <G, M> double get(
065        final Context<G, M> context,
066        final ConceptLattice<G, M> lattice,
067        final Pair<Concept<G, M>, Concept<G, M>> concepts)
068    {
069      return 2d;
070    }
071  },
072  LARGE("Large")
073  {
074    public <G, M> double get(
075        final Context<G, M> context,
076        final ConceptLattice<G, M> lattice,
077        final Pair<Concept<G, M>, Concept<G, M>> concepts)
078    {
079      return 3d;
080    }
081  },
082  HUGE("Huge")
083  {
084    public <G, M> double get(
085        final Context<G, M> context,
086        final ConceptLattice<G, M> lattice,
087        final Pair<Concept<G, M>, Concept<G, M>> concepts)
088    {
089      return 4d;
090    }
091  },
092  EXTENT_DIFFERENCE("Extent Difference")
093  {
094    public <G, M> double get(
095        final Context<G, M> context,
096        final ConceptLattice<G, M> lattice,
097        final Pair<Concept<G, M>, Concept<G, M>> concepts)
098    {
099      return 1d + 6d * Math.sqrt(((double) concepts.second().extent().size() - (double) concepts
100          .first()
101          .extent()
102          .size())
103          / (double) context.rowHeads().size());
104    }
105  },
106  INTENT_DIFFERENCE("Intent Difference")
107  {
108    public <G, M> double get(
109        final Context<G, M> context,
110        final ConceptLattice<G, M> lattice,
111        final Pair<Concept<G, M>, Concept<G, M>> concepts)
112    {
113      return 1d + 6d * Math.sqrt(((double) concepts.first().intent().size() - (double) concepts
114          .second()
115          .intent()
116          .size())
117          / (double) context.colHeads().size());
118    }
119  },
120  EXTENT_RATIO("Extent Ratio")
121  {
122    public <G, M> double get(
123        final Context<G, M> context,
124        final ConceptLattice<G, M> lattice,
125        final Pair<Concept<G, M>, Concept<G, M>> concepts)
126    {
127      return 1d + 6d * (double) concepts.first().extent().size() / (double) concepts.second().extent().size();
128    }
129  },
130  INTENT_RATIO("Intent Ratio")
131  {
132    public <G, M> double get(
133        final Context<G, M> context,
134        final ConceptLattice<G, M> lattice,
135        final Pair<Concept<G, M>, Concept<G, M>> concepts)
136    {
137      return 1d + 6d * (double) concepts.second().intent().size() / (double) concepts.first().intent().size();
138    }
139  },
140  INVERSE_EXTENT_RATIO("Inverse Extent Ratio")
141  {
142    public <G, M> double get(
143        final Context<G, M> context,
144        final ConceptLattice<G, M> lattice,
145        final Pair<Concept<G, M>, Concept<G, M>> concepts)
146    {
147      return 1d + 6d * (1d - (double) concepts.first().extent().size() / (double) concepts.second().extent().size());
148    }
149  },
150  INVERSE_INTENT_RATIO("Inverse Intent Ratio")
151  {
152    public <G, M> double get(
153        final Context<G, M> context,
154        final ConceptLattice<G, M> lattice,
155        final Pair<Concept<G, M>, Concept<G, M>> concepts)
156    {
157      return 1d + 6d * (1d - (double) concepts.second().intent().size() / (double) concepts.first().intent().size());
158    }
159  };
160  private final String name;
161
162  public abstract <G, M> double get(
163      final Context<G, M> context,
164      final ConceptLattice<G, M> lattice,
165      final Pair<Concept<G, M>, Concept<G, M>> concepts);
166
167  private EdgeStroke(final String name)
168  {
169    this.name = name;
170  }
171
172  public final String toString()
173  {
174    return name;
175  }
176}