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
025
026import conexp.fx.core.context.Concept;
027import conexp.fx.core.context.ConceptLattice;
028import conexp.fx.core.context.Context;
029
030public enum ObjectLabelText
031{
032  NONE("None")
033  {
034    public <G, M> String get(
035        final Context<G, M> context,
036        final ConceptLattice<G, M> lattice,
037        final Concept<G, M> concept)
038    {
039      return null;
040    }
041  },
042  OBJECT_LABELS("Object Labels")
043  {
044    public <G, M> String get(
045        final Context<G, M> context,
046        final ConceptLattice<G, M> lattice,
047        final Concept<G, M> concept)
048    {
049      return null;
050    }
051  },
052  EXTENT_SIZE("Extent Size")
053  {
054    public <G, M> String get(
055        final Context<G, M> context,
056        final ConceptLattice<G, M> lattice,
057        final Concept<G, M> concept)
058    {
059      return concept.extent().size() + "";
060    }
061  },
062  EXTENT_PERCENTAGE("Extent Ratio")
063  {
064    public <G, M> String get(
065        final Context<G, M> context,
066        final ConceptLattice<G, M> lattice,
067        final Concept<G, M> concept)
068    {
069      return (int) Math.rint(100d * ((double) concept.extent().size()) / ((double) context.rowHeads().size())) + "%";
070    }
071  },
072  OBJECT_LABELS_SIZE("Object Labels Size")
073  {
074    public <G, M> String get(
075        final Context<G, M> context,
076        final ConceptLattice<G, M> lattice,
077        final Concept<G, M> concept)
078    {
079      return lattice.objectLabels(concept).size() + "";
080    }
081  },
082  OBJECT_LABELS_PERCENTAGE("Object Labels Ratio")
083  {
084    public <G, M> String get(
085        final Context<G, M> context,
086        final ConceptLattice<G, M> lattice,
087        final Concept<G, M> concept)
088    {
089      return (int) Math.rint(100d * ((double) lattice.objectLabels(concept).size())
090          / ((double) lattice.context.rowHeads().size()))
091          + "%";
092    }
093  };
094  private final String name;
095
096  private ObjectLabelText(final String name)
097  {
098    this.name = name;
099  }
100
101  public abstract <G, M> String get(
102      final Context<G, M> context,
103      final ConceptLattice<G, M> lattice,
104      final Concept<G, M> concept);
105
106  public final String toString()
107  {
108    return name;
109  }
110}